Problem Solving · Algorithmic Design
up to +100 XP
Stop 1.2 · Problem Solving · 3 min

Algorithmic Design

Learn to create step-by-step solutions to problems

Learning objectives:
  • Define an algorithm and its characteristics (1.2.1)
  • Express algorithms as flowcharts, written descriptions and code, with benefits and drawbacks (1.2.2–1.2.5)
  • Use sequence, selection and iteration (1.2.6)
  • Trace, find and fix errors, translate and design algorithms (1.2.7–1.2.12)

What an algorithm is

An algorithm is a precise, ordered set of steps that solves a problem or completes a task. A good algorithm is precise (each step is clear and unambiguous) and finite (it always finishes). Its purpose is to describe a solution so that a person or a computer can follow it and get the right result every time.

Three ways to express an algorithm

Flowcharts

SymbolMeaning
Terminator (rounded rectangle)Start or end
RectangleA process
Rectangle with double side linesA sub-process (a separate, defined process)
DiamondA decision (yes/no)
ParallelogramInput or output
ArrowThe flow of logic
LabelText on an arrow, such as Yes or No

The specification's Appendix 2 also includes a connector symbol for linking parts of a flowchart that cannot easily be joined with an arrow.

Benefits: visual and easy to follow, good for non-technical audiences, shows decisions clearly. Drawbacks: slow to draw and edit, large algorithms become hard to read.

Written descriptions

Numbered steps using hierarchical markers, for example 1, 1.1, 1.2, 2, to show sequence and which steps belong inside others.

Benefits: quick to write, needs no special tools, easy for anyone to read. Drawbacks: everyday language can be ambiguous, and long descriptions are hard to follow.

Code

Python 3.10 or later, using the commands in Appendix 2 of the specification.

Benefits: precise, can be run and tested. Drawbacks: needs programming knowledge to read, and syntax details can hide the logic.

Controlling the order of steps

The order matters. A correct set of steps in the wrong order gives the wrong result.

Working with algorithms

# Trace this with mark = 72
mark = int(input("Mark: "))
if mark >= 70:
    print("Distinction")
elif mark >= 50:
    print("Pass")
else:
    print("Fail")
# Output: Distinction
Quick check · 13 questions · up to 100 XP

Check what stuck.

+10 XP each
Question 1

Question 1 of 13

What is an algorithm?

Question 2

Question 2 of 13

Which characteristic means an algorithm must always end?

Question 3

Question 3 of 13

Which flowchart symbol shows a decision?

Question 4

Question 4 of 13

Which flowchart symbol shows an input or output?

Question 5

Question 5 of 13

What is a drawback of expressing an algorithm as a flowchart?

Question 6

Question 6 of 13

How do written descriptions show the order of steps?

Question 7

Question 7 of 13

Which action makes steps repeat?

Question 8

Question 8 of 13

Which is a benefit of expressing an algorithm in code?

Question 9

Question 9 of 13

What does tracing an algorithm mean?

Question 10

Question 10 of 13

An algorithm should output "Pass" for marks of 50 or more but uses if mark > 50. What is wrong?

Question 11

Question 11 of 13 · Match the pairs

Match each flowchart symbol to what it shows.

Terminator
Rectangle
Diamond
Parallelogram
Question 12

Question 12 of 13 · Fill in the blanks

The three actions that control the order of steps are sequence, and .

Question 13

Question 13 of 13 · Coding

Write a function largest(a, b) that returns the bigger of two numbers.

Open the IDE
Hint

Use an if statement to compare a and b.