Fun computer science · Classes 7 to 10
Algorithms: step-by-step thinking
An algorithm is a recipe a computer can follow exactly. Trace what it does one step at a time, and see why some recipes finish much faster than others.
1. Trace a loop
Set where x starts, what it adds each time and how many times the loop repeats. Predict the final x, then run it.
2. Linear search or binary search?
The list holds 2, 4, 6, … 32 in order. Choose the number to find and compare the two methods.
3. Bubble sort, pass by pass
Bubble sort compares neighbours and swaps those that are out of order. Press Next pass and watch the biggest number “bubble” to the end.
Remember in one minute
- An algorithm is a clear set of steps to solve a problem. A loop repeats steps; trace it by writing the variable after each repeat.
- Linear search checks items one by one: up to n comparisons for n items.
- Binary search halves a sorted list each step: at most ⌊log₂ n⌋ + 1 comparisons.
- Bubble sort swaps neighbours that are out of order; after each pass the next-largest item is in place.
Practice now: 3 levels, worked answers, progress tracker →
This is a practice aid made by BodhiScore, not a textbook or an official board resource. Your school’s textbook decides the exact syllabus and the way answers are written. Nothing on this page is saved or sent anywhere. This is a practice aid, not a substitute for your school textbook. These are standard computing facts; where a value depends on a convention (such as 1 KB = 1024 bytes) the question says which one is used.