topic badge

14.04 Flow charts

Lesson

Are you ready?

Do you remember what an iteration is? Try this question.

Examples

Example 1

Follow the algorithm below to fill in the results.

StepInstructionResult
1\text{Start with the number $29$}
2\text{Subtract $1$ from this number}
3\text{Repeat step $2$ three more times}⬚\\⬚\\⬚
4\text{Double the number}
Worked Solution
Create a strategy

Follow each step of the algorithm.

Apply the idea

Step 1 tells us to start with 29, so the first result is 29.

Step 2 tells us to subtract 1 from 29, which gives us 29-1=28.

Step 3 tells us to repeat step 2 three more times. Since step 2 tells us to subtract 1, we need to subtract 1 three times to get: 27,\,26,\,25.

Step 4 tells us to double the last number found in step 3, which is 25.

\displaystyle \text{Result}\displaystyle =\displaystyle 25\times2Double the last number
\displaystyle =\displaystyle 50Evaluate
StepInstructionResult
1\text{Start with the number $29$}29
2\text{Subtract $1$ from this number}28
3\text{Repeat step $2$ three more times}27\\26\\25
4\text{Double the number}50
Idea summary

Iteration means to repeat steps in an algorithm.

Flow charts

This video shows us how to set up and follow a flow chart.

Loading video...

Examples

Example 2

What is the output of this algorithm if the input is 4?

This image shows a flow chart with linear sequence. Ask your teacher for more information.
Worked Solution
Create a strategy

Use the given number as the input and follow each instruction in the flow chart.

Apply the idea
\displaystyle \text{Input}\displaystyle =\displaystyle 4Input the number
\displaystyle 4^2\displaystyle =\displaystyle 16Square the number
\displaystyle \dfrac{16}{2}\displaystyle =\displaystyle 8Divide the number by 2
\displaystyle \text{Output}\displaystyle =\displaystyle 8Output the number
Idea summary

A linear sequence is a flow chart that moves from beginning to end in one straight line. There are no decisions, just a some steps to do.

Branches, loops and print

We can show all our special coding things in a flow chart. This video shows us branches, loops and some special functions like print and set.

Loading video...

Examples

Example 3

What is the output of this algorithm if the input is A=2 and B=5?

This image shows a flow chart with branches. Ask your teacher for more information.
Worked Solution
Create a strategy

Use the given numbers for A and B and follow the flow chart.

Apply the idea
\displaystyle A,\,B\displaystyle =\displaystyle 2, 5Input A=2 and B=5
\displaystyle \text{Is } 2>5\displaystyle =\displaystyle \text{No}Decide if A>B
\displaystyle C\displaystyle =\displaystyle 5-2Find C=B-A
\displaystyle \text{Output}\displaystyle =\displaystyle 3Output C
Idea summary

On a flow chart:

  • Branch is shown by two arrows coming out of a decision box.

  • Iteration is shown as a path that loops back to itself.

  • Print can be used to display an output.

Outcomes

VCMNA221

Design algorithms involving branching and iteration to solve specific classes of mathematical problems

What is Mathspace

About Mathspace