Understanding Algorithm
Understanding Algorithm
1. Understanding Algorithms
algorithms must be :
- unambiguous ( clear )
- step by step
1
Phyu Phyu Aye Chan
1. Written description
2. Flowcharts
3. Pseudocode
4. Program code
1. Written Descriptions
- short sentences
- should be easy to understand and have no unnecessary details
- clear instructions
- should include all the elements found when decomposing a problem
Advantages of WD
Disadvantages of WD
2. Flowchart
2
Phyu Phyu Aye Chan
Start or End
- at the beginning and end of the algorithm
Input or Output
- for values that are put into or taken out from algorithm
Process
- for instructions and calculations
Decision
3
Phyu Phyu Aye Chan
Subroutine
- to reference other flowcharts
Advantages of FC
Disadvantages of FC
- large problem → diagram can become huge and therefore difficult to follow
- any charges to the design may mean a lot of diagram has to be redrawn
4
Phyu Phyu Aye Chan
Features of Pseudocode
Advantages of Pseudocode
Disadvantages of Pseudocode
5
Phyu Phyu Aye Chan
1. Numbers entered are stored in variables with the identifier such as firstNumber and
secondNumber
a. Identifier : a unique name given to a variable or constant
b. must use descriptive names → code is easier to read
2. Results as well are stored such as total
3. Text has to be displayed using single ‘ ‘ or double “ “ quotation marks
4. Variables are displayed without quotation marks
5. Arithmetic Operators
4. Program code
6
Phyu Phyu Aye Chan