Algorithms
Algorithms
Algorithms are the core of computer science: well-defined, finite procedures that transform inputs into outputs. This section covers the design, analysis, and implementation of the algorithms you must understand for A-Level, including their time and space complexity.
Topics Covered
Searching Algorithms
- Linear search — sequential scan; when to use it (unsorted data, small datasets)
- Binary search — on sorted data; the divide-and-conquer paradigm
- Trace tables — stepping through algorithm execution to verify correctness
Sorting Algorithms
- Bubble sort, insertion sort, merge sort, quick sort — their mechanisms, complexity, and stability
- Best-case, average-case, and worst-case analysis using Big-O notation
- Comparison of sorting algorithms — when each is appropriate
Graph Algorithms
- Depth-first search (DFS) and breadth-first search (BFS) — traversal strategies
- Dijkstra’s shortest path — weighted graph optimisation
- Representations — adjacency matrix vs. adjacency list trade-offs
Complexity Analysis
- Big-O, Big-, and Big- notation — formal definitions and practical use
- Time vs. space complexity — analysing both dimensions
- Classifying common algorithms — constant, logarithmic, linear, linearithmic, quadratic, exponential
Study Tips
- Trace algorithms by hand on small inputs before writing code — this builds the intuition needed for exam trace-table questions.
- Learn the complexity classes cold: , , , , , . You should be able to classify any A-Level algorithm instantly.
- Understand why merge sort is and bubble sort is , not just that it is. Exam questions test reasoning, not memorisation.
- Compare algorithms in terms of time, space, and stability — comparison questions appear frequently.
- Practice deriving Big-O from code or pseudocode, counting operations line by line.
How to Use These Notes
Work through the pages in sidebar order. Each page contains definitions, step-by-step traces, worked exam examples, and practice problems. Start with searching and sorting, then move to graph algorithms and complexity analysis.
Notation
Throughout this section we use the following notation:
| Symbol | Meaning |
|---|---|
| Upper bound on growth rate | |
| Lower bound on growth rate | |
| Tight bound (both upper and lower) | |
| Running time as a function of input size | |
| Space complexity as a function of input size |