Comparing searching and sorting algorithms
How many steps an algorithm takes as data grows, and what it needs (e.g. sorted data for binary search). Compare it to choose between linear or binary search, selection or quick sort.
Understanding Comparing searching and sorting algorithms in VCE Software Development U3O1
What it does: Nested loops over the data show selection sort's n x n growth. Doubling the data roughly quadruples the steps. Partitioning values around a pivot splits the problem into smaller parts, which is why quick sort is fast on average. A poor pivot choice gives its worst case. Binary search halves the search area by comparing with the middle item, so the data must already be in order. Linear search works on unsorted data. Sorting costs more steps than one linear scan. Sorting first only pays off if you will search the list many times. A very unbalanced split leaves almost all items on one side, so the partitioning has to be repeated many times. Even splits give the best performance.
Common mistakes: A function header must end with a colon. It should be def linear(items, goal): so the step-counting linear search can run. The best case for linear search is when the target is the first item, which takes 1 step. len(data) steps is the worst case. It should be best_steps = 1.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 156–166) and word search (Modules 142–166).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
algorithm efficiencyFill in the Blanks
Spot the Error
Student with a class code? Join your class →