Algorithm Constructs | |||||||||||||||||||||||||||||||||||||
An algorithm is a sequence of instructions used to solve a problem. Note the word sequence in this definition. It means there is an order to the instructions.
|
|||||||||||||||||||||||||||||||||||||
Algorithm Constructs Pseudocode is a method of writing down an algorithm Pseudocode does not use the syntax of any particular programming language but it does show the structure of a solution. It is important that 'blocks' and loops are indented to show the structure clearly. There are not really any conventions used in pseudocode but I would suggest using the following:
|
|||||||||||||||||||||||||||||||||||||
The basic 'constructs' of an algorithm are : Sequence : A number of instructions is processed one after the other. eg
Selection : The next instruction to be executed depends on a 'condition' :
|
|||||||||||||||||||||||||||||||||||||
Iteration : A number of instructions is repeated.... (a)...a fixed number of times:
[Note in the program that a loop is used to draw the line. This is an example of a 'nested loop' - a loop inside another loop]
(b)....until a condition is met:
|
|||||||||||||||||||||||||||||||||||||