Skip to content
Part IA Lent Term

Examinable Syllabus for Algorithms I

Algorithms I Syllabus (25/26, Lent Term)

The following topics are examinable for the Algorithms I component of CST Paper 1 (one question from a choice of two). The course covers 12 lectures taught by Dr John Fawcett.

Sorting Algorithms

All of the following sorting methods are examinable, including pseudocode, correctness proofs (via loop invariants), and asymptotic analysis:

  • Insertion sort: incremental, Θ(n2)\Theta(n^2) worst case, Θ(n)\Theta(n) best case (sorted input). Stable, in-place. Tight loop makes it fast for small nn.
  • Merge sort: divide and conquer, Θ(nlogn)\Theta(n \log n) worst and average case. Stable. Not in-place (requires Θ(n)\Theta(n) auxiliary space). Solved via Master Theorem or substitution.
  • Quicksort: divide and conquer with partition about a pivot. Θ(n2)\Theta(n^2) worst case (sorted input, or constant split-off), Θ(nlogn)\Theta(n \log n) expected case. In-place (Lomuto or Hoare partition). Instability of partition step makes it unstable.
  • Quicksort with Median-of-Medians: guarantees Θ(nlogn)\Theta(n \log n) worst case by selecting the median as pivot in Θ(n)\Theta(n) time.
  • Heapsort: build a max-heap in Θ(n)\Theta(n), then extract n1n-1 times at O(logn)O(\log n) each. Θ(nlogn)\Theta(n \log n) total. In-place, unstable. Demonstrates the heap data structure.
  • Counting sort: Θ(k+n)\Theta(k + n), where keys are in [0,k][0, k]. Non-comparison; stable. Requires k=O(n)k = O(n) to be linear.
  • Radix sort: sort digit-by-digit using a stable sort (e.g. counting sort) on each digit. Θ(d(n+k))\Theta(d(n + k)) for dd-digit numbers.
  • Bucket sort: assumes uniform distribution over [0,1)[0, 1). Θ(n)\Theta(n) average, Θ(n2)\Theta(n^2) worst.

Sorting lower bounds: any comparison-based sort requires Ω(nlogn)\Omega(n \log n) comparisons. This is an information-theoretic lower bound (decision tree argument).

Asymptotic Notation

All five notations must be understood, with formal definitions and the ability to prove membership:

NotationMeaningFormal definition
O(g(n))O(g(n))Asymptotic upper bound0f(n)cg(n)0 \le f(n) \le c \cdot g(n) for nn0n \ge n_0
Ω(g(n))\Omega(g(n))Asymptotic lower bound0cg(n)f(n)0 \le c \cdot g(n) \le f(n) for nn0n \ge n_0
Θ(g(n))\Theta(g(n))Asymptotically tight boundc1g(n)f(n)c2g(n)c_1 \cdot g(n) \le f(n) \le c_2 \cdot g(n)
o(g(n))o(g(n))Non-tight upper boundFor any c>0c > 0, 0f(n)<cg(n)0 \le f(n) < c \cdot g(n)
ω(g(n))\omega(g(n))Non-tight lower boundFor any c>0c > 0, 0cg(n)<f(n)0 \le c \cdot g(n) < f(n)

Properties: transitivity (all five), reflexivity (O,Ω,ΘO, \Omega, \Theta), symmetry (Θ\Theta only).

Algorithm Design Strategies

  • Incremental: build solution step by step (insertion sort).
  • Divide and conquer: split into non-overlapping subproblems, solve recursively, combine (merge sort, quicksort, quicksort MoM, quickselect, Strassen’s algorithm).
  • Dynamic programming: overlapping subproblems with optimal substructure; memoisation; top-down (recursion + cache) and bottom-up (table filling).
  • Greedy algorithms: locally optimal choice leads to globally optimal solution; requires proof of correctness (exchange argument).
  • Semi-structures: heaps are cheaper to build than fully-sorted structures.

Methods for Solving Recurrences

  • Guess and verify (substitution method): guess a bound, prove by induction.
  • Substitute and spot pattern: expand recurrence, identify arithmetic/geometric series, solve closed form.
  • Recursion tree method: draw call tree, sum costs per level, multiply by number of levels.
  • Master Theorem: for recurrences of form T(n)=aT(n/b)+f(n)T(n) = aT(n/b) + f(n). Three cases based on comparing f(n)f(n) with nlogban^{\log_b a}.

Data Structures (Algorithms I Only)

Elementary Structures

  • Pointers, NIL, objects.
  • Stacks (LIFO): PUSH, POP, O(1). Array and linked-list implementations.
  • Queues (FIFO): ENQUEUE, DEQUEUE, O(1). Circular buffer array implementation.
  • Singly and doubly linked lists; cyclic variants; sentinel nodes.
  • Rooted trees: with/without parent pointers, fixed/variable child counts.

Binary Search Trees

  • BST property; SEARCH, INSERT, DELETE, MINIMUM, MAXIMUM, PREDECESSOR, SUCCESSOR.
  • All Θ(h)\Theta(h); h=Θ(n)h = \Theta(n) worst case, Θ(logn)\Theta(\log n) expected for random insertion.
  • Inorder traversal produces sorted order.

Balanced Search Trees

  • B-trees: minimum degree tt; t1t-1 to 2t12t-1 keys per node; tt to 2t2t children. Height logt((n+1)/2)\le \log_t((n+1)/2). Search, insert (top-down splitting), delete (redistribute/merge). All O(logn)O(\log n). Disk I/O motivation.
  • 2-3-4 trees: B-tree with t=2t=2. 1—3 keys, 2—4 children per node. Conceptual bridge to red-black trees.
  • Red-black trees: five colour properties, black-height, height 2log(n+1)\le 2\log(n+1). Insertion fix-up (3 cases: recolour, zig-zag rotation, zig-zig rotation). Isomorphism with 2-3-4 trees. All operations O(logn)O(\log n).

Hash Tables

  • Dictionary ADT: INSERT, DELETE, SEARCH.
  • Hash functions: division method, multiplication method, range reduction.
  • Collision resolution by chaining (4 variants).
  • Collision resolution by open addressing (linear, quadratic, double hashing).
  • Primary and secondary clustering.
  • Load factor α=n/m\alpha = n/m, resizing, amortised Θ(1)\Theta(1) insert.
  • Universal hashing: definition, example family, adversarial protection.

Priority Queues and Heaps

  • Binary heaps: min-heap and max-heap. Structural property (complete tree) and ordering property (parent \le children for min-heap).
  • Array representation: root at index 1, children at 2i2i and 2i+12i+1, parent at i/2\lfloor i/2 \rfloor.
  • MAX-HEAPIFY (REHEAPIFY): O(logn)O(\log n).
  • BUILD-MAX-HEAP: Θ(n)\Theta(n).
  • HEAPSORT: Θ(nlogn)\Theta(n \log n).
  • Priority queue operations: INSERT, EXTRACT-MIN/MAX, DECREASE-KEY, all O(logn)O(\log n) via heap; also implementable via red-black trees.

Order Statistics

  • MINIMUM and MAXIMUM in Θ(n)\Theta(n) via linear scan; simultaneous min+max in 3n/2\le 3\lfloor n/2 \rfloor comparisons.
  • Quickselect: expected Θ(n)\Theta(n), worst case Θ(n2)\Theta(n^2). With Median-of-Medians: worst case Θ(n)\Theta(n).

Tripos Question Format

Algorithms I is assessed in CST Paper 1, questions 7 and 8 (one to be answered from two). Typical structure:

  • Part (a): theory, definition, proof (e.g. state a loop invariant, prove correctness, derive a height bound).
  • Parts (b—d): application, algorithm design, tracing, or modifying an algorithm for a variant problem.

Past papers from 2006—2026 are available. The syllabus is broadly stable across years.

Summary of Examinable Topics

CategoryTopics
SortingInsertion, Merge, Quick, Heap, Counting, Radix, Bucket; stability; lower bounds
AsymptoticsOO, Ω\Omega, Θ\Theta, oo, ω\omega; definitions and properties
RecurrencesSubstitution, tree method, Master Theorem
Design strategiesIncremental, divide and conquer, DP, greedy, semi-structures
ProofsLoop invariants (initialisation, maintenance, termination); induction
Elementary DSStacks, queues, linked lists, trees
BSTsSearch, insert, delete; degeneracy
Balanced treesB-trees, 2-3-4 trees, red-black trees; isomorphism
Hash tablesChaining, open addressing, universal hashing, resizing
HeapsHeapify, heapsort, priority queues
Order statisticsQuickselect, Median-of-Medians