Year 8 › Algorithms: search and sort › Lesson 4 of 5
Year 8 · Summer 1 · Algorithms: search and sort Comparing efficiency by counting comparisons
Topic 12 Searching and sorting
KS3 Computing · Searching finds an item. Sorting puts items in order. Some algorithms are hugely faster than others on big lists, and the difference grows as the list grows.
Computational Thinking Cambridge Lower Secondary Computing 0860
You will learn to Count the comparisons a search or a sort makes on a short list. Compare how the number of comparisons grows when the list doubles in length. Explain that n² grows much faster than n log n as the list gets longer. Choose an algorithm for a situation: sorted or not, big or small.
Success criteria I can fill in a table of comparisons for lists of 8, 16 and 32 items. I can say that doubling a list adds only one check to a binary search. I can choose a search or a sort for a scenario and give a reason.
Linear search Check every item in turn.
Binary search Search a sorted list by halving it each step.
Bubble sort Swap neighbours until a whole pass makes no swaps.
Insertion sort Slide each item into its place in the sorted part.
Merge sort Split into single items, then merge back in order.
Comparing them ★ RememberThere's rarely one best algorithm, only the best one for this data.
Mark this lesson as done Saved on this device.
← Previous lesson Insertion sort and merge sort, unplugged Next lesson → Code a linear search in Python