19
© Boardworks Ltd 2013 1 of 19 9.2 Algorithms and flow charts Teacher’s notes in the Notes Page Flash activity (these are not editable) Useful web links in the Notes Page Icons: Unit 9 Computing Concepts Worksheet or support sheet available

9.2 Algorithms and flow charts

Embed Size (px)

DESCRIPTION

Curriculum links This presentation supports the following sections 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

Citation preview

Page 1: 9.2 Algorithms and flow charts

© Boardworks Ltd 20131 of 19

9.2 Algorithms and flow charts

Teacher’s notes in the Notes Page

Flash activity (these are not editable) Useful web links in the Notes PageIcons:

Unit 9 Computing Concepts

Worksheet or support sheet available

Page 2: 9.2 Algorithms and flow charts

© Boardworks Ltd 20132 of 19

Curriculum links

This presentation supports the following areas of knowledge in the Naace Curriculum Framework for KS3 ICT:

This presentation supports the following sectionsof 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

Skills – Problem solving

Technical understanding – Programming and control

Page 3: 9.2 Algorithms and flow charts

© Boardworks Ltd 20133 of 19

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.

Page 4: 9.2 Algorithms and flow charts

© Boardworks Ltd 20134 of 19

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?

Page 5: 9.2 Algorithms and flow charts

© Boardworks Ltd 20135 of 19

Basic flow charts and algorithms

Here is a basic algorithm with its corresponding flow chart:

Put bread in the toaster

Start

Bread in toaster

Press handle

Wait 2 minutes

Toast on plate

Butter toast

Stop

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.

Press the handle

Wait 2 minutes

Put the toast on a plate

Butter the toast

Page 6: 9.2 Algorithms and flow charts

© Boardworks Ltd 20136 of 19

Let’s dance!

Page 7: 9.2 Algorithms and flow charts

© Boardworks Ltd 20137 of 19

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.

Start

Stand up straight

Bend knees

Left hand on hip

Point with left hand

Right hand on hip

Point with right hand

Stop

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.

Page 8: 9.2 Algorithms and flow charts

© Boardworks Ltd 20138 of 19

Adding a decision

Start

Stand up straight

Bend knees

Left hand on hip

Point with left hand

Right hand on hip

Point with right hand

Stop

Is music playing?No

Yes

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.

To make Dave dance until the song ends, we need to add a loop and an extra symbol to our flow chart.

To repeat our instructions, we can either write them out many times, or we can use a loop.

Page 9: 9.2 Algorithms and flow charts

© Boardworks Ltd 20139 of 19

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.

Start/stop Process Decision

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:

Other common symbols include:

Inputs/outputs

Stored data

Printed document

Page 10: 9.2 Algorithms and flow charts

© Boardworks Ltd 201310 of 19

Functions of symbols

Page 11: 9.2 Algorithms and flow charts

© Boardworks Ltd 201311 of 19

Making a bear system flow chart

This is a system flow chart for making a toy bear.

Stuff the bear

Stop

Start

Clothed the bear?

Stuffed the bear?

Stitched the bear?

Stitch the bear

Clothe the bear

Yes

Yes

Yes

No

No

No

Our problem will be solved when the bear is complete.

Page 12: 9.2 Algorithms and flow charts

© Boardworks Ltd 201312 of 19

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 conditionsthey can process data at a high speedthey 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?

Page 13: 9.2 Algorithms and flow charts

© Boardworks Ltd 201313 of 19

Log flume

Page 14: 9.2 Algorithms and flow charts

© Boardworks Ltd 201314 of 19

Log flume system flow chart

Page 15: 9.2 Algorithms and flow charts

© Boardworks Ltd 201315 of 19

Where is the flow?

Page 16: 9.2 Algorithms and flow charts

© Boardworks Ltd 201316 of 19

Advantages and disadvantages

Algorithms:

Flow charts:

are written in simple textare easy for the author to understandcan be hard for another programmer to understandcan be confusing if the system being described is too complex.

use a clearly laid out structure that all programmers follow

use symbols

are less likely to be misunderstoodare better for describing complex systems.

Page 17: 9.2 Algorithms and flow charts

© Boardworks Ltd 201317 of 19

Algorithm or flow chart?

Page 18: 9.2 Algorithms and flow charts

© Boardworks Ltd 201318 of 19

Summary quiz

Page 19: 9.2 Algorithms and flow charts

© Boardworks Ltd 201319 of 19

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 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.

I know the meanings of the symbols used in flow charts.