Ready-to-use computing activity
Algorithm Race
Teacher overview
Prior knowledge: Learners should understand that algorithms can be compared using the same input data.
Learning objective: Compare search and sorting algorithms using observed comparisons, swaps and trace evidence.
Starter
Which do you think will use fewer comparisons on [2, 4, 6, 8, 10]: linear search or binary search?
Main task
- Predict which algorithm will finish first on the given data.
- Run linear search and binary search for the same present target.
- Record comparisons and result.
- Run bubble sort and insertion sort on the same reverse-sorted data.
- Use evidence to write a short conclusion.
Support prompts
- Keep the data the same for a fair comparison.
- Do not use binary search until the data is sorted.
- A swap count is not the same as a comparison count.
Challenge
Find a data set where insertion sort does very little work.
Plenary or exit question
Why is fastest on one data set not the same as always fastest?
