AQA · GCSE · Computer Science

    Course version: 8525 · Version from Sept 2020

    Understand and explain how the linear search algorithm works.

    Full specification wording

    Searching algorithms: Understand and explain how the linear search algorithm works.

    A linear search checks items one at a time, in order, from the start of the list until the target is found or the list ends.

    Checked against the AQA 8525 specification (opens in a new tab) on .

    • Point 1 of 4

    Study notes

    From the checked teaching notes for this specification point.

    The idea

    A linear search checks items one at a time, in order, from the start of the list until the target is found or the list ends. To explain it, describe the method: examine the first item and compare it with the target; if it matches, stop and report the position; if not, move to the next item and repeat. If the end of the list is reached without a match, report that the target is not present. For example, searching for 7 in the list 3, 9, 7, 1 compares 3 (no match), then 9 (no match), then 7 (match at the third position) and stops. It works on unsorted as well as sorted data, and in the worst case it examines every item.

    What earns the marks

    • States that a linear search examines items one at a time, in sequence, starting from the first item.
    • Describes comparing each item with the target value and moving to the next item when there is no match.
    • States that the search stops and reports the position when a match is found.
    • States that if the end of the list is reached with no match, the target is reported as not found.
    • Recognises that a linear search can be used on unsorted data and may need to check every item in the worst case.

    Common mistakes and how to put them right

    • Claiming a linear search requires the data to be sorted first.

      Put it right: It works on unsorted data because it simply checks items in order.

    • Saying the search continues through the whole list even after a match is found.

      Put it right: It stops as soon as the target is located and reports that position.

    • Confusing linear search with binary search by describing repeated halving of the list.

      Put it right: Linear search moves through items one at a time and does not split the list.

    Exam tips

    • Use a short worked example list and state each comparison in order, showing where the search stops.
    • Include both outcomes: a successful search that reports a position, and an unsuccessful search that reports the target is absent.
    • Use precise wording such as 'compares each item in turn with the target' rather than vague phrases like 'looks through the list'.

    Try the lesson

    The start of the Searching algorithms: Understand and explain how the linear search algorithm works. lesson, made from checked teaching notes for this specification point.

    Have a go first

    How does a linear search look for a target value in a list?

    There is more to this lesson

    The full lesson goes on to check your understanding and help you earn the marks. Create a free account to carry on, with your progress saved.

    Carry on with the full lesson

    A week of Premium from your first lesson · Then the free plan continues · No card, no charge

    Test your understanding of Searching algorithms: Understand and explain how the linear search algorithm works.

    Active recall beats re-reading. Take an instant quiz now to test what you’ve learned and lock it into long-term memory.

    Take topic quiz

    A week of Premium from your first lesson · Then the free plan continues · No card, no charge