Problem solving and first programs · 2 / 5

Flowcharts: drawing an algorithm

Today you will draw an algorithm as a flowchart, follow it with a trace table, and find a bug in one.

builders 120 min

Flowcharts: drawing an algorithm

Today you will draw an algorithm as a flowchart, follow it with a trace table, and find a bug in one.

Teacher block: Ocen explains the road

Ocen explains to Akello how to walk from the taxi park to the market.

Ocen says: Go straight. At the big mango tree, if the road is wet, go round by the church, otherwise go straight. Then go past the shop. Then, wait, go back to the tree if you did not see the shop.

Akello shakes her head.

Akello says: I am lost.

She takes a stick and draws in the sand: boxes, with arrows between them. “Now follow the arrows,” she says.

Ocen follows the arrows with his finger. “Oh. Now I see where my own words went wrong.”

Why is a picture with arrows easier to follow than words?

Teacher block: Recall from yesterday and last week

Think. Then show with your fingers.

  1. What is the first of the four steps for solving a problem? 1. Understand 2. Plan 3. Look back
  2. “Repeat steps 5 and 6 until a bean is soft” is a: 1. sequence 2. decision 3. repetition
  3. Breaking a big problem into small problems is called: 1. decomposition 2. storage 3. tracing
  4. A trace table is used to: 1. draw pictures 2. follow how the values change, step by step 3. save files

Teacher block: The shapes and three kinds of step

A flowchart is a picture of an algorithm. Each step is a shape. Arrows show the order.

Shape Name What it means
Oval Start and end Where the algorithm begins and finishes
Rectangle Action One thing to do
Diamond Decision A question with the answer Yes or No. It has two arrows out, labelled Yes and No
Arrow Flow Which step comes next

Rules:

  1. There is one Start.
  2. Every path ends at an End.
  3. A diamond has two arrows out, labelled Yes and No.
  4. Draw from top to bottom.

The three kinds of step from last week:

Example: the boda fare (an example, not a real price). A trip of 3 km or less costs 3000 shillings. A longer trip costs 3000 plus 1000 for each km over 3.

YesNoStartRead kmIs km 3 orless?Fare is 3000Fare is 3000 plus1000 times (km minus3)Say the fareEnd

Press Walk through and follow it for a trip of 5 km. Which way do you go at the diamond?

Teacher block: Wonder, the drawing that showed wasted steps

In 1921, two engineers in the USA, Frank and Lillian Gilbreth, showed other engineers a new kind of drawing. They called it a process chart. They watched how a job was done, step by step, and drew each step as a shape joined by arrows.

With the whole job on one page, they could see the steps that were wasted, and cut them. Lillian Gilbreth was also a psychologist, and she kept doing this work for many years after Frank died. Later, the first computer programmers drew flow diagrams in the same way, to plan their programs before they wrote them.

If you drew your morning as shapes and arrows, which step could you cut or move?

Teacher block: Words to flowchart, and trace it

Convert numbered steps to a flowchart. Last week we wrote this:

  1. Wash the beans.
  2. Put the beans and water in the pot.
  3. Put the pot on the fire.
  4. Repeat steps 5 and 6 until a bean is soft.
  5. Wait 10 minutes.
  6. Press one bean between two fingers.
  7. Take the pot off the fire.

A step becomes a rectangle. “Repeat until” becomes a diamond with an arrow going back. That is Flowchart 3.

Trace a flowchart. Put a finger on Start. Move along the arrows. At each box, write down what changes.

Count and add:

  1. Start.
  2. Set total to 0.
  3. Set count to 1.
  4. Is count greater than 4? Yes: go to 7. No: go to 5.
  5. Add count to total.
  6. Add 1 to count. Go back to 4.
  7. Say total.
  8. End.
Round Is count greater than 4? total count
Start 0 1
1 No 1 2
2 No 3 3
3 No 6 4
4 No 10 5
Last check Yes 10 5

It says 10.

YesNoStartSet total to 0Set count to 1Is countgreater than4?Add count to totalAdd 1 to countSay totalEnd

Teacher block: Find the bug, and the worksheet

Here is a flowchart that should say 1, then 2, then 3, and stop. It is question 4 on the worksheet. Follow it. What does it say? What is the bug?

FlowchartsName:

Name:

1. Turn these steps into a flowchart. Draw it on the back of this sheet.

  1. Plug in the charger.
  2. Look at the battery.
  3. If the battery is full, unplug the charger and stop.
  4. Otherwise, wait 10 minutes and go back to step 2.

Which shape is used for step 3?

2. The boda fare flowchart. Follow it for 6 km. What is the fare?

For 10 km?

3. Follow this flowchart.

Box Shape Words inside Arrow goes to
1 Oval Start 2
2 Rectangle Set total to 0 and count to 2 3
3 Rectangle Add count to total 4
4 Rectangle Add 2 to count 5
5 Diamond Is count greater than 8? Yes to 6. No back to 3
6 Rectangle Say total 7
7 Oval End none

Fill in the trace.

Round total count Is count greater than 8?
Start
1
2
3
4

What does it say?

4. This flowchart should say 1, then 2, then 3, and stop.

Box Shape Words inside Arrow goes to
1 Oval Start 2
2 Rectangle Set count to 1 3
3 Rectangle Say count 4
4 Rectangle Add 1 to count 5
5 Diamond Is count greater than 3? Yes to 6. No back to 2
6 Oval End none

Follow it. Does it ever stop?

Which kind of bug is it: unclear, missing, wrong order, or never ends?

Write what you change to fix it.

Your teacher will read this answer. Choose who is learning (top of the page) to save this answer.

CheckQuestion 1 of 4

Which shape shows a decision?

Laptop block: Task card, my flowchart

With no teacher. Read the card. Follow it. Ask your partner first.

Your pair: one driver and one navigator. Swap every 10 minutes. If there are 3 of you, one is the timekeeper and joins a pair as a second navigator. Rule: do not change another person’s file.

Before you start: if the Lenovo is off, switch it on. Choose one algorithm to draw. Use your algorithm from last week (the file in your projects folder), or your morning steps from last week’s home mission. It needs at least one decision and, if you can, one repetition.

Round 1 (10 minutes): driver one draws

  1. Plan on paper first. Draw a quick flowchart with a pencil on scrap paper. Check the four rules: one Start, every path ends, two arrows out of every diamond, labels Yes and No.
  2. Scroll down to the drawing pad on this page. It has a brush, line, box and circle, colours, a rubber, undo, and Save my picture.
  3. Draw your flowchart.
    • Use the box for actions and the circle for Start and End.
    • There is no diamond tool. Draw a diamond with four lines.
    • Use the line tool for arrows. Draw the arrowhead with two short lines.
    • Write the words with the brush, small and slowly. If the writing is hard, write a short word or a number in each shape and put the words on a list under the chart.
    • Use one colour for decisions, to see them quickly.
  4. Predict first: will a stranger be able to follow your arrows without asking you a question?
  5. Click Save my picture. The browser saves the picture as a download, usually in the Downloads folder. Its name starts with the name chosen in “Who is learning?” and ends with the word picture, the date and .png, for example akello-picture-2026-12-08.png. If a box asks where to save, choose Downloads.
  6. Find the saved picture in Downloads. Move it into your week2 folder inside projects, and rename it flowchart- plus your name, keeping the ending, for example flowchart-akello.png. (Windows: File Explorer, then drag it. Mac: Finder, then drag it.)

The navigator checks each shape: right shape? labelled arrows? one Start? every path ends?

Swap! Driver two does the same for their own algorithm.

Round 2 (10 minutes): driver two draws. (Same steps as Round 1.)

Swap!

Round 3 (10 minutes): follow and trace

  1. Look at your partner’s flowchart. Put a finger on Start and follow the arrows.
  2. Open the text editor. Type a trace table for it with one row for each round, with the values that change. For example:
Round | count | total
Start | 1 | 0
1 | 2 | 1
2 | 3 | 3
  1. If the flowchart has a bug, type it under the table: the box number, what went wrong, and the kind (unclear, missing, wrong order, never ends). Save the file in week2 as trace- plus the name.
  2. Be kind. Say “I found a bug”, not “your chart is bad”.

Last 5 minutes: fix. Take your bug report back. Draw the fix on the pad (use undo and the rubber), and click Save my picture again. Find the new file in Downloads, move it to week2, and rename it to end with -v2, for example flowchart-akello-v2.png. Leave both laptops on at the end.

Keep the pad open until your picture is saved. If you leave or reload the page, the drawing is lost.

Drawing pad

Stuck? Before you ask anyone, try three things:

  1. Read the step again, slowly, out loud.
  2. Ask your partner: “What do you see? Where did we save the picture?”
  3. Use the search box in File Explorer or Finder and type the start of your file name. If it still fails, write the problem on paper and carry on.

Laptop block: Challenges

Choose one level.

Bronze

Check that every arrow out of a diamond is labelled Yes or No, and that your decision shapes are all one colour. Save the picture again.

Silver

Add one loop to your flowchart if it has none (an arrow back, with a stop signal in a diamond). Trace it with a trace table typed in a file, and check that it ends.

Gold

Draw the flowchart for the largest of three numbers. Save it as flowchart-largest.png in week2. Then trace it for 3, 18 and 11 with a typed trace table. Write what it says. Then change one arrow on purpose to make a bug and write the kind of bug it is.

For gold: when you have finished, check your drawing against this one. Press Walk through and follow it with 3, 18 and 11.

YesNoYesNoStartRead a, b and cSet biggest to aIs b greaterthan biggest?Set biggest to bIs c greaterthan biggest?Set biggest to cSay biggestEnd

Say it out loud: follow my arrows

Stand up and talk for one minute.

Show us your flowchart. Where is the decision? Where is the loop, or where could one go? What did your partner find?

Use this shape: My flowchart is about … . The decision asks … . The bug my partner found was … , and I fixed it by … .

Exit question

Show with your fingers.

You see an arrow that goes back up to an earlier box. What kind of step is it?

  1. Sequence
  2. Decision
  3. Repetition

Then say one sentence: “Today I learned that …”

Tick your skills.

Home mission

Paper (everyone). Draw a flowchart for something you do at home, for example boiling water for tea, or deciding what to wear if it might rain. Use one decision and one loop. Ask someone at home to follow your arrows with a finger. Find one bug. Bring it tomorrow.

Phone (only if a family phone is free, and you have asked). Think about how a phone lock works. Draw the flowchart: enter the PIN, is it right?, and what happens on Yes and on No. Do not write anyone’s real PIN.

I can...

Pick your name first, at the top of the page.

← How to solve a hard problemHow computers count: binary →

Use the arrow keys