Algorithm Detective
Crack open algorithms — read them, trace them, and say exactly what they do.
Revise this, the fun way
Play it interactively, earn XP and build a streak — free.
Start revising freeWhat you'll cover
Algorithm Detective 🕵️
Give a computer a problem and it needs a plan — an **algorithm**. Your job in this case: read the plan, work out what it does, and prove it. By the end you'll trace an algorithm line by line and name its purpose in one sentence — exactly what the exam rewards.
Three big ideas
• **Algorithm** — a precise sequence of steps that solves a problem. • **Decomposition** — breaking a big problem into smaller, easier sub-problems. • **Abstraction** — removing detail that doesn't matter, to focus on what does (like a map showing roads, not every tree).
Spot the abstraction
Which of these is **abstraction**?
- Ignoring detail that doesn't matter, to focus on the key idea
- Breaking a problem into smaller sub-problems
- A precise sequence of steps to solve a problem
Inputs → process → outputs
Almost every algorithm has the same shape: • **Inputs** — the data it's given. • **Process** — what it does with that data. • **Outputs** — the result it produces.
Label the parts
To find the average of some marks: the marks are the _____, adding them up and dividing is the _____, and the average is the _____.
How we write algorithms
Two common ways: **pseudo-code** (plain, code-like steps) and **flowcharts** (boxes and arrows). You need to read *and* complete both. Here's pseudo-code that reports the larger of two numbers: `INPUT a` · `INPUT b` · `IF a > b THEN OUTPUT a ELSE OUTPUT b`
Read it
Using that algorithm, what is output when `a = 4` and `b = 7`?
- 4
- 7
- 11
Dry-run with a trace table
To work out what an unfamiliar algorithm does, **trace** it: go line by line and write down every change, updating each column **in order** (left to right). Watch a running total build as a loop adds `1`, then `2`, then `3`.
Trace it yourself
An interactive activity.
Now — what does it DO?
Grade-9 detectives don't describe every line. After tracing, state the **overall purpose** in one precise sentence. That algorithm didn't just "add `i` to `total`" — step back: it worked out a **running total**.
Name its purpose
In one sentence, what is that algorithm's purpose?
- It adds up the whole numbers from 1 to 3
- It counts up to 3
- It outputs 6 three times
Good tracing habits
Pick the TWO things a good trace does.
- Update each column in order, left to right
- Write down every change to a variable
- Describe what each line does, separately
- Guess the final output
In the exam 🎯
Case closed. Grade-9 habits for algorithms: • Trace **accurately under time** — one column at a time, in order (the classic slip is updating out of order). • State the **overall purpose** in one sentence, not a line-by-line retelling. • Know your trio: **algorithm**, **decomposition**, **abstraction**.