Height — number of edges from root to deepest leaf
Binary Trees
Binary Search Trees (BST)
In a binary tree, each node has at most two children (left and right). A binary search tree (BST) has the ordering property: left child < parent < right child.
BST EXAMPLE (inserting 5,3,7,1,4)
5
/ \
3 7
/ \
1 4
Applications
Real-World Uses
GRAPHS
Road/rail networks
Social networks
Internet routing
TREES
File systems (folders)
HTML DOM structure
BST for fast searching
AQA Exam Style
Practice Question
AQA 7517 — Paper 1 Style
A network of cities is represented as a weighted directed graph. (a) Give ONE difference between a directed and an undirected graph. [1] (b) State ONE advantage of using an adjacency list over an adjacency matrix. [1] (c) The cities are: A, B, C, D. Draw the adjacency matrix for: A→B(4), A→C(2), B→D(1), C→D(3). [3]
[5 marks]
1 mark
(a) In a directed graph edges have direction; in undirected they can be traversed both ways
1 mark
(b) Adjacency list uses less memory for sparse graphs (only stores existing edges)
3 marks
(c) 4×4 matrix: A→B=4, A→C=2, B→D=1, C→D=3, all others=0
Summary
Key Points to Remember
Graph = vertices + edges; can be directed/undirected, weighted/unweighted
Adjacency matrix — O(V²) space, O(1) lookup; best for dense graphs
Adjacency list — O(V+E) space; best for sparse graphs
Tree = connected acyclic graph; root, parent, child, leaf
BST — left < parent < right; O(log n) search when balanced