TactivergeLite

Lite / Discovering How the World Works / 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 · Reviewed by the founders' mentors · Full interactive version

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.

Predict

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

  1. Act
  2. Decide
  3. Measure
Guess first, then reveal

Measure first. You can't compare or decide until you know the temperature. Putting steps in a flowchart forces you to notice what each one needs from the one before.

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.

What the interactive shows (text version)

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.

You can also open the interactive on the full site when you have a faster connection.

Understand

Four shapes

Most flowcharts need only four shapes:

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

Intuitive

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.

Technical

A flowchart is a directed graph: nodes are operations or decisions, edges are control flow. Each decision node has exactly two outgoing edges labelled true and false.

Applied

Hospital staff, pilots and factory workers all use flowcharts for emergencies ('Is the patient breathing? Yes → … No → …') because they are fast to follow under pressure and leave no gaps.

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

Practice

Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.

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?

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.

Reflect

Was it easier to spot mistakes in the drawing or in written sentences? Why?

Write your answer on paper or in your own notes. Lite never stores what you write.

← What is an algorithm?Some algorithms are better than others →