Expressing algorithms as flowcharts

Supporting children in writing algorithms, sequencing, selection and repetition

Algorithms

To download this example, click here

Flowcharts are a common way of designing and documenting simple processes or programs, where individual steps are shown as boxes and connected by arrows.

Please note: abstraction is commonly used to filter out unnecessary components within commands, however, for this exercise, abstraction will refer to the simplification of code to support children in writing algorithms.

The examples on the right are specific to the Scratch game ‘The Flying Dragon’ – to see a demonstration of this game, click here.

Fig 1.1 demonstrates  what needs to occur for the dragon’s position to be controlled by the micro:bit. As you can see, this algorithm contains a lot of information which is not all necessary, therefore to present this algorithm as a flowchart (Fig 1.2), decomposition has been used to break down it down into its key steps. The process of abstraction has also been used to discard unnecessary details which will make it easier to understand. Here, it is also important to recognise that sequencing is imperative because this determines the order in which the algorithm is followed. For example, if the dragons size was set after the micro:bits tilt, the dragon would change size half way through the game which is an unwanted feature. 

At the beginning of the flowchart (Fig 1.2) there is a loop that causes a code to repeat. This can only be stopped when a selection is made, in this case, by pressing button B. Further down the flowchart, there is another loop which causes code to repeat. This loop is not stopped by selection and instead continues even when a selection is made. This loop represents the tilt of the micro:bit, causing it to be in a constant state of readiness.

Fig 1.3 demonstrates how the original algorithm and flowchart can be expressed in a programming language such as Scratch.


Activity idea: Produce a flow chart for a written algorithm

For KS1 pupils

This activity involves children being provided with a day-to day algorithm such as ‘cleaning teeth’ where they then have to adapt the algorithm into a flowchart. This provides children with a meaningful context to learn about the key concepts of computing because it is a familiar routine, therefore they will already have an understanding of the steps within this algorithm.

This activity can teach children about the process of abstraction where they can draw upon their knowledge of this routine and abstract (remove) unnecessary details from it in order to produce a flowchart. The abstracted flowchart will then act as a model for a child where an algorithm can be designed using programming language. Setting out algorithms using a flowchart can help children to see how logical reasoning processes of computational thinking are utilised – logical reasoning could also be used by encouraging the children to discuss with each other about what may happen if some of the code is swapped around. For example, if you place the ‘rinse your tooth brush’ instruction straight after ‘put tooth paste on the tooth brush’, there would be no tooth paste to clean your teeth with, therefore this algorithm would be ineffective. This idea reinforces the need for sequences to be thought out and precise.

By carrying out this activity, children will develop their understanding of Scratch and its visual programming language because it will give them the opportunity to explore how they can use events such as ‘when’ or controls such as ‘repeat’ to carry out the algorithm effectively.

The principles outlined above, such as abstraction can support children in their understanding of programming languages, where they will come to realise that it is not necessary to include every single detail that comes from an instruction within an algorithm. This realisation will support children when they move onto coding using visual programming languages. The idea of sequencing, outlined above, where algorithms can be ineffective if they are ambiguous and complicated supports children in understanding that programming languages need to be precise and unambiguous in order to achieve a specific goal.

Please note that:

Although this is a beneficial activity for younger pupils, it is still necessary to understand that the computing National Curriculum for KS1 requires children to understand how algorithms are implemented as programs on digital devices, therefore it is important for them to then apply the knowledge that they have built about abstraction, sequencing, logical reasoning and algorithms in this activity to digital systems, where they could use their flowchart to start constructing algorithms in code.


Activity idea: Produce the algorithm in code

For KS2 Pupils

This activity focuses on children being able to construct algorithms in code. Pupils can be given a flowchart (downloadable here) and be required to use Scratch blocks to put the algorithm together.

This activity supports children in understanding sequence, selection and repetition where children are having to use the flowchart and its arrows to determine what is happening within the algorithm. Similarly, children will be able to develop their understanding of algorithms, where they are required to understand how they are implemented on digital devices. 

In terms of Scratch programming, children are having to identify the key principles of computational thinking like selection and repetition and discover how these algorithms can be translated into code. Similarly, when children have written their algorithms in code, they will be able to try them out on Scratch to see if the outcomes that are produced are what was intended. If they were not, children can demonstrate another key principle of computational thinking which is debugging, where they will have to decompose the code and work out which part is causing their algorithm to glitch.

How could you use this activity to determine how children are getting on within these outcomes of the National Curriculum?

Formative assessment can be used to ensure that the children can explain how these simple algorithms work using logical reasoning.


Print Friendly, PDF & Email