Searching Algorithms
Aligned to the AQA 7517 specification
- Level
- Intermediate
- Reading time
- 5 min
- Published
- 13 June 2026
- Updated
- 1 July 2026
On this page
Key takeaways
- Linear search examines each element in turn on unsorted or sorted data, with best case O(1) and worst and average case O(n).
- Binary search requires the array to be sorted in ascending order and runs in O(log n) because each comparison halves the remaining search space.
- Binary search uses integer division for the midpoint, `mid ← (low + high) DIV 2`, and updates `low ← mid + 1` or `high ← mid - 1` after each comparison.
- Binary tree search uses the BST ordering property (left subtree less than the root, right subtree greater) and is O(log n) average but O(n) for a degenerate unbalanced tree.
- Binary search operates on a sorted array using index arithmetic, while BST search operates on a tree using node pointers; they share average complexity but are different algorithms.
Something not quite clicking?
Ask Aica to explain any part of this differently. Free, takes 30 seconds.
Key terms
- Linear search
- A search (also called sequential search) that examines each element in turn until the target is found or the list is exhausted; works on unsorted data.
- Binary search
- A search that halves the remaining search space at each step by comparing the target with the middle element; requires a sorted array.
- Binary tree search
- A search that finds a value in a binary search tree by following the BST ordering property down left or right branches.
- Binary search tree (BST)
- A tree where all values in the left subtree are less than the root and all values in the right subtree are greater.
- Best case
- The most favourable input scenario, such as O(1) for linear search when the target is the first element.
- Worst case
- The least favourable input scenario, such as O(n) for linear search when the target is last or not present.
- Balanced tree
- A BST whose structure halves the search space at each node, giving O(log n) search; an unbalanced (degenerate) tree gives O(n).
Frequently asked questions
Binary search eliminates half the search space each step by comparing the target with the middle element and deciding which half to keep. This decision is only valid if the data is sorted; applied to an unsorted array it produces incorrect results without raising an error.
Each comparison cuts the remaining elements in half: from n to n/2 to n/4 and so on. The search ends when n/2^k = 1, so k = log₂ n. For n = 1000 at most 10 comparisons are needed.
No. BST search is O(log n) only for a balanced tree, where each node halves the search space. In the worst case, such as inserting elements in sorted order, the tree degenerates into a single chain like a linked list and search becomes O(n).
Generate revision on any topic you study
Type any topic you're studying and Aicademy generates a complete lesson, quiz, and flashcard set, personalised to your level.
Lessons on anything
Structured, level-matched lessons on any topic you study
Practice quizzes
Find out what you actually know before the exam does
Flashcard sets
Lock in key concepts with instant revision cards
Ask Aica
Stuck on something? Get a clear explanation, any time
Reverse Polish Notation
Sorting Algorithms
Related lessons
8 min
6 min
6 min