Skip to main content
EnglandComputer Science

OCR A-Level Computer Science Algorithms and complexity: searching, sorting and Big-O made exam-ready

A deep-dive OCR H446 guide to Component 02 section 2.3, algorithms. Covers the searching algorithms (linear, binary, binary tree) with traces, the sorting algorithms (bubble, insertion, merge, quick), graph and tree traversal with Dijkstra and A*, and Big-O notation with the complexity classes used to compare algorithms.

Generated by Claude Opus 4.815 min readH446 2.3

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

Jump to a section
  1. What this section actually demands
  2. Searching and sorting
  3. Traversal and analysis
  4. How this section is examined
  5. Check your knowledge

What this section actually demands

Section 2.3 is the algorithms paper's analytical core. OCR rewards two things: accurately tracing an algorithm step by step (trace tables for searches and sorts, a queue or stack for traversals), and reasoning about efficiency with Big-O. You should be able to run each algorithm by hand and state and justify its complexity.

This guide walks through the topics in order and sets out the exam patterns OCR repeats. Each topic has a matching dot-point page with practice; this overview ties them together.

Searching and sorting

Searching algorithms and their complexity covers linear search (O(n)O(n)), binary search (O(logn)O(\log n), requiring a sorted list) and binary tree search (O(logn)O(\log n) balanced, O(n)O(n) unbalanced), each with a trace. The recurring skill is tracing a binary search and justifying why halving gives logarithmic time.

Sorting algorithms and their complexity covers bubble and insertion sort (O(n2)O(n^2)) and the divide-and-conquer merge and quick sort (O(nlogn)O(n \log n), quick sort O(n2)O(n^2) worst case). The classic questions trace a pass of bubble or insertion sort and explain why merge sort is O(nlogn)O(n \log n).

Traversal and analysis

Graph and tree traversal algorithms covers breadth-first (queue) and depth-first (stack) traversal, the three binary-tree traversals (in-order giving sorted output on a BST), and the shortest-path algorithms Dijkstra and A*, set as "BFS versus DFS" and "Dijkstra versus A*" questions.

Big-O notation and algorithm analysis covers the complexity classes from O(1)O(1) to O(2n)O(2^n), why constants and lower-order terms are dropped, and determining the Big-O of code (single loop O(n)O(n), nested loops O(n2)O(n^2)), used to compare and choose algorithms.

How this section is examined

A typical OCR profile for section 2.3:

  • Trace tables. Trace a binary search, a sort pass, or a graph traversal step by step.
  • Complexity statements. Give and justify the Big-O of each standard algorithm.
  • Comparison. BFS versus DFS (with data structures and uses); Dijkstra versus A*.
  • Determine Big-O. Read a code fragment's loops and state its time complexity, ordering the classes.

Check your knowledge

A mix of recall and applied questions covering the section. Attempt them under timed conditions, then check against the solutions.

  1. State the precondition for binary search. (1 mark)
  2. State the worst-case time complexity of bubble sort. (1 mark)
  3. State the data structure used by a depth-first traversal. (1 mark)
  4. State which binary tree traversal gives a BST's values in ascending order. (1 mark)
  5. Order O(1)O(1), O(n)O(n), O(logn)O(\log n) and O(2n)O(2^n) from most to least efficient. (2 marks)
  6. State the time complexity of an algorithm with two nested loops, each running nn times. (1 mark)

Sources & how we know this

  • computer-science
  • a-level-ocr
  • ocr-computer-science
  • algorithms
  • searching
  • sorting
  • big-o