Searching & sorting

GCSE Computer Science · Unit 3: Algorithms

Searching & sorting notes

Fact-checked by a second, independent AI review.

Concise overview of common searching and sorting techniques, how they work, when to use them, and what exam questions usually ask.

Linear search (sequential search)
Check each item in order until you find the target or reach the end; works on any list but is slow on large data.
Binary search
Requires a sorted list; repeatedly check the middle item and halve the search space until found or not present.
Bubble sort
Repeatedly compares adjacent items and swaps them; simple but slow for large lists (O(n^2)).
Insertion sort
Builds a sorted section by inserting each new item into its place; efficient for small or nearly sorted lists.
Sorting concepts
Stability (preserves equal items' order), in-place (uses little extra memory), time complexities vary by algorithm (best/worst/average).

Remember it: Mnemonic for binary search: MID, HALVE, DECIDE – keep splitting the middle to halve the search space.

Exam tip: Markers want clear definitions, correct complexity notes (e.g., O(log n) for binary search, O(n^2) for bubble sort), ability to trace steps, and justification for choosing an algorithm in a given scenario.

Syllabus checklist

  • Searching & sorting: core ideas
  • Terms and typical exam questions for "Algorithms" in GCSE Computer Science (OCR/AQA)

Practice questions

  1. 1. Which data structure is best for implementing binary search?

    Answer checked

    Show answer

    Answer: Array. Binary search requires random access to elements, which arrays provide.

  2. 2. Linear search checks each item until a match is found.

    Answer checked

    Show answer

    Answer: True. Linear search may need to inspect every element in the worst case.

  3. 3. A sorting algorithm that divides the list into halves and conquers is ____ sort.

    Answer checked

    Show answer

    Answer: merge. Merge sort uses divide-and-conquer by splitting halves.

  4. 4. Which sorting algorithm has best average-case O(n log n) and uses a divide-and-conquer approach?

    Answer checked

    Show answer

    Answer: Merge sort. Merge sort performs O(n log n) on average and uses divide-and-conquer.

  5. 5. In the worst case, a linear search on n elements makes ____ comparisons.

    Answer checked

    Show answer

    Answer: n. A linear search may compare each element once, totaling n comparisons.

Practise searching & sorting as a game

Hearts, combos, streaks and an AI tutor that explains every answer. Start free.

Start free

More from Unit 3: Algorithms