0% found this document useful (0 votes)
4 views8 pages

Algorithm Design

The document outlines the Program Development Life Cycle (PDLC), which includes stages such as analysis, design, coding, testing, and maintenance. It emphasizes the importance of clearly defining problems, using tools like abstraction and decomposition, and employing documentation methods like flowcharts and pseudocode during the design phase. Additionally, it covers coding practices, iterative testing, and the use of various data types and control structures in programming.

Uploaded by

Chipo Saini
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views8 pages

Algorithm Design

The document outlines the Program Development Life Cycle (PDLC), which includes stages such as analysis, design, coding, testing, and maintenance. It emphasizes the importance of clearly defining problems, using tools like abstraction and decomposition, and employing documentation methods like flowcharts and pseudocode during the design phase. Additionally, it covers coding practices, iterative testing, and the use of various data types and control structures in programming.

Uploaded by

Chipo Saini
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Algorithm Design & Problem-Solving

Program Development Life Cycle (PDLC)

 Analysis

 Design

 Coding

 Testing

 Maintenance

Analysis

 Before solving a problem, it is essential to define and document the


problem clearly, known as the "requirements specification" for the
program.

 The analysis stage involves using tools like abstraction and


decomposition to identify the specific requirements for the program.

 Abstraction focuses on the essential elements needed for the solution


while eliminating unnecessary details and information.

 Decomposition involves breaking down complex problems into smaller,


more manageable parts that can be solved individually.

 Daily tasks can be decomposed into constituent parts for easier


understanding and solving.

Design

 The program specification 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.

 Documentation methods such as structure charts, flowcharts, and


pseudocode can be used to document the program's design formally.

Coding and iterative testing

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


 Each module of the program is written using a suitable programming
language.

 Testing is conducted to ensure that each module functions correctly.

 Iterative testing is performed, which involves conducting modular


tests, making code amendments if necessary, and repeating tests until
the module meets the required functionality.

Testing

 The completed program or set of programs is executed multiple times


using various test data sets.

 This testing 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 identify and address
potential issues and errors.

 The testing phase aims to verify the overall functionality and


performance of the program by evaluating 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
until each one only performs a single action. A structure diagram
diagrammatically represents a top-down design. Example below.
Pseudocode & Flowcharts

 Pseudocode - Verbal representation of an algorithm (a process or set


of steps) and flowcharts are a diagrammatic representation.

 Flowcharts: A flowchart shows diagrammatically 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 question in which


all of the functions 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 until the accepted riders are 8. After they are
8, it outputs the number of rejected riders and tells the rest that they are
ready to go!

Pseudocode

 Declaration & Usage of Variables & Constants

o Variable – Store of data which changes during execution of the


program (due to user input)

o Constant – Store of data that remains the same during the


execution of the program

 Basic Data Types

o 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 – Multiple 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 respectively. (It is recommended to use input and output
commands)

INPUT Name

OUTPUT "Hello Mr." , Name

// Alternatively //

READ Name

PRINT "Hello Mr," , Name

 Declaration 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 multiple values of


same datatype under single name

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

 Assignment - Each variable is assigned using a left arrow.

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

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

 Conditional Statements:

IF…THEN…ELSE…ENDIF
CASE…OF…OTHERWISE…ENDCASE – Multiple
conditions and corresponding consequences \n

 Loop Structures:

 FOR…TO…NEXT : Will run for a determined/known amount of times

REPEAT… UNTIL – Will run at least once till condition is satisfied; Verification

is done after running code WHILE…DO…ENDWHILE –


May not ever run; Verification is done before running code

Note: When using conditions in these loop


structures and conditional 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 left 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