Standard algorithms: totals, max, min, average, counting

About this lesson: Standard algorithms: totals, max, min, average, counting

In short

Start at 0 and add each value.

Standard algorithms: totals, max, min, average, counting

What you'll explore

Totalling: A running total
Start at 0 and add each value.
Counting: Count what matches
Add 1 each time a value meets a condition.
Average and maximum: One pass through the data
Track the total and the largest value as you go.
Efficiency: One pass or sort first?
To find the maximum, one pass is faster than sorting.
Check yourself: Minimum
To find the smallest value, what should min start as?

Also in this lesson

  • Step by step
  • Watch out for these
  • More than the lesson
  • Stretch your brain
  • Try it yourself

Words to know

Totalling
Adding values into a running total.
Counting
Adding 1 when a condition is met.
Initialise
Give a starting value.
One pass
Visiting each item once.

Sources

  • Raspberry Pi Foundation, Isaac Computer Science: standard algorithms
  • Python documentation: built-in functions max, min, sum
  • BBC Bitesize, GCSE Computer Science: algorithms
  • Khan Academy: algorithms

An interactive lesson with a live experiment: move the sliders, press the buttons and answer quick questions. 5 short steps and a 8-question quiz. Part of the Family plan. Written and checked by Shalo Lab. Last updated 11 November 2026.

← Reading and writing text files · Designing and testing a complete program →

All lessons in Term 1 · Computing · Age 15