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.

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
← Reading and writing text files · Designing and testing a complete program →