Algorithms and flow charts
Download
Report
Transcript Algorithms and flow charts
9.2 Algorithms and flow charts
Unit 9 Computing Concepts
Icons:
1 of 19
Flash activity (these are not editable)
Useful web links in the Notes Page
Teacher’s notes in the Notes Page
Worksheet or support sheet available
© Boardworks Ltd 2013
Curriculum
links sections
This presentation
supports the following
of the Programme of Study for KS3 Computing:
design, use and evaluate computational abstractions that
model the state and behaviour of real-world problems and
physical systems
understand several key algorithms that reflect computational
thinking, such as ones for sorting and searching; use logical
reasoning to compare the utility of alternative algorithms for
the same problem
This presentation supports the following areas of knowledge
in the Naace Curriculum Framework for KS3 ICT:
Skills – Problem solving
Technical understanding – Programming and control
2 of 19
© Boardworks Ltd 2013
Learning objectives
By the end of this presentation we will have learned:
what algorithms and flow charts are
how algorithms and flow charts are structured
how to add loops to a flow chart
the meanings of the symbols used in flow charts
how flow charts can be used for a system
how flow charts can be used for a control system
to identify when to use an algorithm or flow chart.
3 of 19
© Boardworks Ltd 2013
What is an algorithm?
An algorithm is a list of instructions
used to solve a problem.
Algorithms break problems down
into small steps and end when the
problem is solved.
There are many types of algorithms used
in the real world, such as when we use a
recipe or follow directions. Whenever we
are using a set of instructions to reach an
end goal, we are using an algorithm.
Can you think of any more examples of algorithms?
4 of 19
© Boardworks Ltd 2013
Basic flow charts and algorithms
A flow chart is a visual algorithm, using
symbols instead of lines of text for each
instruction. The symbols help us to
understand the type of instruction that is
being shown.
Here is a basic algorithm with its
corresponding flow chart:
Start
Bread in toaster
Press handle
Wait 2 minutes
Put bread in the toaster
Press the handle
Wait 2 minutes
Toast on plate
Butter toast
Put the toast on a plate
Butter the toast
5 of 19
Stop
© Boardworks Ltd 2013
Let’s dance!
6 of 19
© Boardworks Ltd 2013
Adding loops to a flow chart
The flow charts we have looked at
so far have been very basic, simply
following a list of instructions.
However, we may wish to repeat
some of our instructions until
something changes.
For example, Dave
probably wouldn’t
perform these actions
once and then stop.
He could repeat these
actions 30 times, or
he could repeat them
until the song ends.
7 of 19
Start
Point with right hand
Right hand on hip
Point with left hand
Left hand on hip
Bend knees
Stand up straight
Stop
© Boardworks Ltd 2013
Adding a decision
To repeat our instructions, we
can either write them out many
times, or we can use a loop.
To make Dave
dance until the song
ends, we need to
add a loop and an
extra symbol to our
flow chart.
By adding the decision symbol,
we can ask if the music is playing.
If it is, the sequence will run.
If not, the sequence will stop.
Start
No
Is music playing?
Yes
Point with right hand
Right hand on hip
Point with left hand
Left hand on hip
Bend knees
Stand up straight
Stop
8 of 19
© Boardworks Ltd 2013
System flow chart symbols
Sometimes you may need to use a flow chart to show how an
entire computer system will work, with different sequences
working together. This is called a system flow chart.
System flow charts use symbols to represent different
sequences in a system. We have already seen three of the
symbols used in a systems flow chart:
Start/stop
Process
Decision
Other common symbols include:
Inputs/
outputs
9 of 19
Stored
data
Printed
document
© Boardworks Ltd 2013
Functions of symbols
10 of 19
© Boardworks Ltd 2013
Making a bear system flow chart
This is a system flow chart
for making a toy bear.
Start
Stuffed
the bear?
No
Stuff the
bear
No
Stitch
the bear
No
Clothe
the bear
Yes
Stitched
the bear?
Yes
Our problem will be solved
when the bear is complete.
Clothed
the bear?
Yes
Stop
11 of 19
© Boardworks Ltd 2013
Controlling a device
We may wish to use a system flow chart to work out how to
control a device, such as a piece of machinery in a factory.
Control devices work by using input and output devices that
are processed by a computer or a microprocessor.
Microprocessors can be very small.
They do the ‘thinking’ in a control device.
Control devices are used because:
they can work in hazardous conditions
they can process data at a high speed
they can repeat tasks in exactly the same way for an
unlimited length of time, provided the conditions are good.
What might stop a control device from working?
12 of 19
© Boardworks Ltd 2013
Log flume
13 of 19
© Boardworks Ltd 2013
Log flume system flow chart
14 of 19
© Boardworks Ltd 2013
Where is the flow?
15 of 19
© Boardworks Ltd 2013
Advantages and disadvantages
Algorithms:
are written in simple text
are easy for the author to understand
can be hard for another programmer
to understand
can be confusing if the system being
described is too complex.
Flow charts:
use symbols
use a clearly laid out structure that all
programmers follow
are less likely to be misunderstood
are better for describing complex systems.
16 of 19
© Boardworks Ltd 2013
Algorithm or flow chart?
17 of 19
© Boardworks Ltd 2013
Summary quiz
18 of 19
© Boardworks Ltd 2013
AFL check
How did you do?
Copy these actions to
show how much you agree
with the statements.
I know what algorithms and flow charts are.
I know how algorithms and flow charts are structured.
I know how to add loops to a flow chart.
I know the meanings of the symbols used in flow charts.
I know how flow charts can be used for a system.
I know how flow charts can be used for a control system.
I can identify when to use an algorithm or flow chart.
19 of 19
© Boardworks Ltd 2013