Lesson 3 Presenting Algorithms
Lesson 3 Presenting Algorithms
1
Pre-knowledge: analyse the flowchart
by asking questions about it
Algorithm A STAR
T
Algorithm B
STAR
T Observe traffic
Is there
CROSS
any
ROAD ON WAIT
approachi
ng Ycar
STO
E
P
S
Cross road
now
STOP
2
How to use pseudo code to
present an Algorithm
Pseudo code :
START
Task: Cross the road
Begin Observe
traffic
Observe traffic
While traffic approaching do
Is there any
Wait
ON
approaching WAIT
car
Observe traffic Y
E
Endwhile S
Cross road
the condition has been met now
STOP
4
Algorithms -
activity 1
5
Characteristics of a good
Algorithm
One activity per step.
Clear instructions.
The Algorithm should have a clear beginning and end.
Completeness – all the steps should be formulated as
part of the solution.
The steps should be in the correct order.
All the steps should be related to the task to be
completed – no unnecessary steps or information
The Algorithm should be efficient. Make use of
decisions and repetition to make the algorithm as
short as possible
6
Algorithms -
activity 1 - solution Largest
STAR Number
2> Yes =
T
largest Number
N 2
Get the value o
Largest =
of number1
number1
Get the
Number Largest
value of
3> =
number2 Yes
largest Number
Get the N 3
value of o
number3 Largest =
number1
Largest =
number1 Display the
value: Largest
7
STOP
Algorithms -
activity 2