Skip to main content
EnglandComputer ScienceSyllabus dot point

How do linear and binary search work, how do graph traversals explore data, and how efficient is each?

Searching and traversal algorithms: linear search and binary search with their conditions and efficiency, and the breadth-first and depth-first traversals of trees and graphs.

An Eduqas Component 1 answer on searching: how linear search and binary search work, the precondition that binary search needs sorted data, their time complexities, and how breadth-first and depth-first traversals explore trees and graphs.

Generated by Claude Opus 4.814 min answer

Reviewed by: AI editorial process; not yet individually human-reviewed

Have a quick question? Jump to the Q&A page

Jump to a section
  1. What this dot point is asking
  2. The answer
  3. Examples in context
  4. Try this

What this dot point is asking

Eduqas wants you to describe linear search and binary search, state binary search's precondition and each algorithm's efficiency, and describe how breadth-first and depth-first traversals explore trees and graphs. Search is one of the most heavily examined algorithm topics, usually with a trace and a complexity statement.

The answer

Linear search

Binary search

Breadth-first and depth-first traversal

Examples in context

A phone's contact search uses binary search because the contacts are kept sorted by name. A spell-checker scanning an unsorted buffer uses linear search. Breadth-first traversal powers shortest-route features in unweighted maps and "degrees of separation" in social graphs; depth-first traversal explores file-system trees, solves mazes and underlies cycle detection. The efficiency comparisons here lead directly into the next dot points on sorting and on Big-O notation, where the same complexity vocabulary is formalised.

Try this

Q1. State the precondition for binary search and its time complexity. [2 marks]

  • Cue. The list must be sorted; complexity is O(logn)O(\log n).

Q2. A breadth-first traversal uses which auxiliary data structure? [1 mark]

  • Cue. A queue.

Q3. Give one situation where linear search is more appropriate than binary search. [1 mark]

  • Cue. When the list is unsorted (or very small), so sorting it first to enable binary search would not be worthwhile.

Exam-style practice questions

Practice questions written in the style of WJEC Eduqas exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.

Eduqas 20205 marksA sorted array contains 1,4,7,9,12,15,20,251, 4, 7, 9, 12, 15, 20, 25. Using a binary search, show the steps taken to find the value 1515, stating the index examined at each step, and give the time complexity of binary search.
Show worked answer →

Binary search on indices 00 to 77 (up to 3 marks). Step 1: middle index =(0+7)÷2=3= (0 + 7) \div 2 = 3, value 99; 15>915 > 9, so search the upper half, indices 44 to 77. Step 2: middle =(4+7)÷2=5= (4 + 7) \div 2 = 5, value 1515; found at index 55.

Time complexity (up to 2 marks): binary search halves the search space each step, so it is O(logn)O(\log n).

Markers reward the repeated halving with correct middle indices, the comparison that discards half the array each time, and the O(logn)O(\log n) complexity. A common error is searching the wrong half after the comparison.

Eduqas 20224 marksCompare a breadth-first traversal with a depth-first traversal of a graph, stating the auxiliary data structure each uses and one situation where breadth-first is preferable.
Show worked answer →

Breadth-first explores all neighbours of the current node before moving outward level by level, using a queue to hold the nodes to visit next (up to 2 marks).

Depth-first follows one branch as deep as possible before backtracking, using a stack (or recursion, which uses the call stack) (up to 1 mark).

Breadth-first is preferable when you need the shortest path in an unweighted graph, because it reaches nearer nodes first (up to 1 mark).

Markers reward the queue for breadth-first, the stack for depth-first, and the shortest-path use of breadth-first.

Related dot points

Sources & how we know this