0% found this document useful (0 votes)
28 views

Algorithm Design

The document discusses the program development life cycle (PDLC) which includes analysis, design, coding, testing, and maintenance. It then provides more details on each step: analysis involves problem definition and decomposition; design uses the analysis to guide program development; coding develops modules based on the design; testing ensures correct module and program functionality; and structure diagrams and pseudocode can document the design. Flowcharts are also discussed as a way to visually represent algorithms and tasks.

Uploaded by

rajvir.ramdas
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Algorithm Design

The document discusses the program development life cycle (PDLC) which includes analysis, design, coding, testing, and maintenance. It then provides more details on each step: analysis involves problem definition and decomposition; design uses the analysis to guide program development; coding develops modules based on the design; testing ensures correct module and program functionality; and structure diagrams and pseudocode can document the design. Flowcharts are also discussed as a way to visually represent algorithms and tasks.

Uploaded by

rajvir.ramdas
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Algorithm Design & Problem-Solving

Program Development Life Cycle (PDLC)

• Analysis

• Design

• Coding

• Tes�ng

• Maintenance

Analysis

• Before solving a problem, it is essen�al to define and document the problem clearly, known
as the "requirements specifica�on" for the program.

• The analysis stage involves using tools like abstrac�on and decomposi�on to iden�fy the
specific requirements for the program.

• Abstrac�on focuses on the essen�al elements needed for the solu�on while elimina�ng
unnecessary details and informa�on.

• Decomposi�on involves breaking down complex problems into smaller, more manageable
parts that can be solved individually.

• Daily tasks can be decomposed into cons�tuent parts for easier understanding and solving.

Design

• The program specifica�on derived from the analysis stage is used as a guide for program
development.

• During the design stage, the programmer should clearly understand the tasks to be
completed, the methods for performing each task, and how the tasks will work together.

• Documenta�on methods such as structure charts, flowcharts, and pseudocode can be used
to document the program's design formally.

Coding and itera�ve tes�ng

• The program or set of programs is developed based on the design.

• Each module of the program is writen using a suitable programming language.

• Tes�ng is conducted to ensure that each module func�ons correctly.

• Itera�ve tes�ng is performed, which involves conduc�ng modular tests, making code
amendments if necessary, and repea�ng tests un�l the module meets the required
func�onality.

Tes�ng

• The completed program or set of programs is executed mul�ple �mes using various test data
sets.
• This tes�ng process ensures that all the tasks within the program work together as specified
in the program design.

• Running the program with different test data can iden�fy and address poten�al issues and
errors.

• The tes�ng phase aims to verify the overall func�onality and performance of the program by
evalua�ng its behaviour with various inputs.

Structure Diagrams

• Every computer system is made up of sub-systems, which are in turn made up of further sub-
systems.

• Structure Diagrams – The breaking down of a computer system into sub-systems, then
breaking each sub-system into smaller sub-systems un�l each one only performs a single
ac�on. A structure diagram diagramma�cally represents a top-down design. Example below.

Pseudocode & Flowcharts

• Pseudocode - Verbal representa�on of an algorithm (a process or set of steps) and


flowcharts are a diagramma�c representa�on.

• Flowcharts: A flowchart shows diagramma�cally the steps required to complete a task and
the order that they are to be performed

• Algorithm: These steps, together with the order, are called an algorithm
An example of a flowchart is given below from a past paper ques�on in which all of the func�ons of a
flowchart are shown:
This flowchart’s task is to check if a rider’s height is more the requirement (1.2) in this case. It then
counts un�l the accepted riders are 8. A�er they are 8, it outputs the number of rejected riders and
tells the rest that they are ready to go!

Pseudocode

• Declara�on & Usage of Variables & Constants

o Variable – Store of data which changes during execu�on of the program (due to user
input)

o Constant – Store of data that remains the same during the execu�on of the program

• Basic Data Types

Integer – Whole Number e.g. 2; 8; 100

o Real – Decimal Number e.g. 7.00; 5.64

o Char – Single Character e.g. a; Y

o String – Mul�ple Characters (Text) e.g. ZNotes; COOL

o Boolean – Only 2 Values e.g. True/False; Yes/No; 0/1

• Input & Output (READ & PRINT) – Used to receive and display data to the user
respec�vely. (It is recommended to use input and output commands)

INPUT Name

OUTPUT "Hello Mr." , Name

// Alterna�vely //

READ Name

PRINT "Hello Mr," , Name

• Declara�on of variable - A variable/constant can be declared by the following manner

DECLARE [Variable Name] : [DATATYPE OF VARIABLE]

• Array: Array is similar to variable but it can store mul�ple values of same datatype under
single name

DECLARE [ARRAYNAME] : ARRAY [Lower Limit : Upper Limit ] OF [DATATYPE]

• Assignment - Each variable is assigned using a le� arrow.

[VARIABLE NAME] <---- [Value to be assigned]

ArrayName [IndexValue] <---- [Value to be assigned]

• Condi�onal Statements:

IF…THEN…ELSE…ENDIF
CASE…OF…OTHERWISE…ENDCASE – Mul�ple condi�ons and corresponding consequences \n

• Loop Structures:

• FOR…TO…NEXT : Will run for a determined/known amount of �mes

REPEAT… UNTIL – Will run at least once �ll condi�on is sa�sfied; Verifica�on is done a�er running
code
WHILE…DO…ENDWHILE – May not ever run; Verifica�on is done before running code

Note: When using condi�ons in these loop structures and condi�onal statement, it has to be kept in
mind that it can be done in two ways.

1. use of a Boolean variable that can have the value TRUE or FALSE

2. comparisons made by using coparison operators, where comparisons are made from
le� to right

IF [BOOLEAN VARIABLE]

THEN

OUTCOME

ELSE

OUTCOME

ENDIF

IF ((CONDITION 1) OR ( CONDITION 2)) AND (CONDITION 3) AND (CONDITION 4)

THEN

OUTCOME

ELSE

OUTCOME

ENDIF

You might also like