Flowcharts and Pseudocode Lesson Three
Flowcharts and Pseudocode Lesson Three
Lesson Three
Learning Objective
• To design, use and evaluate computational abstractions that model the state and
behaviour of real-world problems and physical systems.
Success Criteria
• To perform an algorithm trace.
• To use inputs and outputs in flowcharts.
• To use Flowgorithm to build and test flowchart algorithms.
High-Low Hedgehogs
Flo the hedgehog likes to play a game with her friend Sue.
You may have played this game yourself. This is how it goes:
• Flo thinks of a number between 1 and 100.
• Sue then tries to guess what the number is.
• If Sue’s guess is too low, then Flo will answer: “too low, guess again”.
(No surprises there!)
• If Sue’s guess is too high, then Flo will answer: “too high, guess again”.
• If Sue’s guess is correct, then Flo will answer: “that’s right!”
• Then Sue thinks of a number between 1 and 100 and Flo has to guess.
Next
High-Low Hedgehogs
OK so I’ve thought of a number…
Is it 50?
Is it 75?
Is it 63?
Start
… and so on …
High-Low Hedgehogs
Here’s a better answer. Why is this a better flowchart?
Start
No Ye
Is guess too high? s Too high – try again.
No
That’s right!
Stop
Algorithm Tracing
Sometimes it’s useful to do an Algorithm Trace. This means stepping through the
algorithm (in this case our flowchart) one step at a time.
Let’s imagine that Person 1 picks the number 26….
Start
Start
Start
No
Algorithm Tracing
Person 2 now makes a guess of 34.
34 is higher than 26 so this time the result is ‘Too high – try again.’
Start
Ye
Is guess too high? s Too high – try again.
Algorithm Tracing
Finally, Person 2 gets lucky and guesses 26.
26 is not lower or higher than 26 so the result is ‘That’s right!’ and the game
is over.
Start
No
Ye
Is guess too high? s Too high – try again.
No
That’s right!
Stop
Inputs and Outputs
We can improve our flowchart even further by using inputs and outputs.
Keywords
An input is information (data) that we put into an algorithm.
An output is information that we get out of the algorithm.
This shape is a
Input / Output parallelogram.
Inputs and Outputs
Let’s add these input and output boxes to
Start our High-Low Hedgehog flowchart:
Click on OK.
Flowgorithm
Step seven:
Finally …
Double-click on the If box:
Then in the
If Properties window type:
age > 18
Click OK.
Flowgorithm
Next
Testing Flowcharts
Click on the green triangular Play button at the top of the Flowgorithm window:
I’m starving!
Further challenge: can you find the pseudocode for this flowchart?
Let’s Bring It All Together
Keywords
Stepping through an algorithm one step at a time and looking at inputs,
values and outputs is called an Algorithm Trace or Dry Running.
Keywords
An input is information (data) that we put into an algorithm.
An output is information that we get out of the algorithm.
Success Criteria
• To know how to perform an algorithm trace.
• To use inputs and outputs in flowcharts.
• To use Flowgorithm to build and test flowchart algorithms.
Nailing It Down
Flowgorithm is a very useful program.