Skip to content
Tactiverge

School/◇ Explorer/Week 20

Drawing algorithms as flowcharts

A greenhouse heater has no idea what a plant is. How can a simple drawing keep seedlings alive all night?

About 25 min · 3 goals · Checked by automated tests; not yet reviewed by an educator

1.Why should I care?

Before engineers write code, they often draw it. A flowchart lets a whole team, including people who don't program, check an algorithm for mistakes. It is the most widely used design drawing in computing and control.

  • ◇ Read a flowchart with start, step, decision and end shapes.
  • ◇ Draw a flowchart for a short algorithm with one decision.
  • ◇ Follow a flowchart for given inputs and say what happens.

2.Predict

A greenhouse controller repeats: measure the temperature, compare it with 18 °C, decide, act. Which step should come first?

Guess first. Being wrong here is how the surprise works.

3.Discover

Match the greenhouse parts to their jobs, then put one turn of the control loop in order: measure, compare, decide, act. Sketch it as boxes and arrows as you go.

Can't use the interactive? Read a description instead

The greenhouse activity can be replaced by this description: the parts are a thermometer (measures temperature), a setpoint (the temperature we want, 18 °C), a controller (compares and decides), a heater (adds heat), a vent and glass (lose heat) and the cold night (pulls the temperature down). One turn of the loop is: measure the temperature, compare it with the setpoint, decide whether to heat, act by switching the heater, then measure again.

4.Understand

Four shapes

Most flowcharts need only four shapes:

  • Rounded box: start or end.
  • Rectangle: do a step ("turn heater on").
  • Diamond: ask a yes/no question ("colder than 18 °C?"), with two arrows out.
  • Arrows: show what comes next.

Decisions split the path

A diamond is where an algorithm becomes intelligent: the path depends on the answer. Every diamond must have both a Yes and a No arrow, or the machine doesn't know what to do half the time.

Arrows can loop back

An arrow that points back to an earlier box makes the steps repeat. A thermostat's flowchart loops back to 'measure' for ever. You'll study loops properly in week 23; for now, notice how easy they are to see in a drawing.

Explain it another way

A flowchart is like a board game path: you move along the arrows, and at some squares you must answer a question to know which way to go.

Worked example 1

Draw a flowchart for: 'If it is raining, take an umbrella. Then leave the house.'

Start → diamond 'Raining?' → Yes arrow to rectangle 'Take umbrella' → arrow to 'Leave house'; the No arrow from the diamond goes straight to 'Leave house' → End. Both branches meet again before the end.

Common mix-ups

  • Flowcharts are just for beginners.
    ✓ Professional engineers use them to design and check algorithms, especially for safety-critical systems.
  • A decision only needs an arrow for the interesting answer.
    ✓ Every decision needs a path for both Yes and No.

5.Practice

Practice, not a test. Wrong answers get a hint and another try.

Practice 1

Which flowchart shape asks a yes/no question?

Practice 2

A flowchart diamond asks 'Door open?' and has only a Yes arrow. What's the problem?

Practice 3

Flowchart: Start → 'Temperature below 18 °C?' Yes → 'Heater on'; No → 'Heater off' → back to Start. The thermometer reads 20 °C. What happens?

Practice 4

A flowchart has a start, an end, three action rectangles and two decision diamonds. How many arrows leave the decision diamonds altogether?

6.Apply it

Draw a flowchart for a smart bin that opens its lid when someone's hand is near, waits 5 seconds, then closes. Include at least one diamond and make the chart loop back so it works all day.

Open BUILD 007: Design a Smart Greenhouse →

7.Reflect

Concepts: Algorithms, searching and complexity · Decisions and loops