In this lesson
- Break a problem into smaller parts
- Write an algorithm as numbered steps
Explanation
Computational thinking breaks a problem into parts (decomposition), ignores irrelevant detail (abstraction), spots patterns and writes precise steps (an algorithm). A good algorithm is unambiguous, finite and handles unusual inputs.
Worked example
Finding the largest of n numbers: set max to the first number; for each remaining number, if it is larger than max, set max to it; report max.
Practice
Write algorithms for: (a) counting vowels in a sentence, (b) checking whether a year is a leap year (divisible by 4, except centuries not divisible by 400).