Binary Search Trees
Aligned to the AQA 7517 specification
- Level
- Intermediate
- Reading time
- 8 min
- Published
- 6 June 2026
- Updated
- 1 July 2026
On this page
Key takeaways
- A binary tree is a rooted tree in which every node has at most two children, the left child and the right child.
- In a binary search tree, for every node all values in its left subtree are less than the node's value and all values in its right subtree are greater, and this holds at every node.
- In-order traversal (left subtree, root, right subtree) outputs the values of a BST in ascending sorted order, but only for a tree that satisfies the ordering property.
- The three traversals differ only in when the root is processed: in-order is in the middle, pre-order is before the children, and post-order is after the children.
- BST search is O(log n) only for a balanced tree; a degenerate tree built from a sorted insertion sequence behaves like a linked list and degrades to O(n).
Worth saving these ideas?
Turn what you've read into instant revision cards. Free to get started.
Key terms
- Tree
- A connected, undirected graph with no cycles, so there is exactly one path between any two vertices.
- Rooted tree
- A tree in which one vertex is designated the root, creating a hierarchy where every other node has exactly one parent.
- Leaf
- A node with no children.
- Binary tree
- A rooted tree in which every node has at most two children, referred to as the left child and the right child.
- Binary search tree (BST)
- A binary tree with an ordering property where each node's left subtree holds smaller values and its right subtree holds larger values.
- In-order traversal
- A traversal that visits the left subtree, then the root, then the right subtree, outputting a BST's values in ascending order.
- Pre-order traversal
- A traversal that visits the root, then the left subtree, then the right subtree; used for copying a tree.
- Post-order traversal
- A traversal that visits the left subtree, then the right subtree, then the root; used for emptying a tree and converting infix to RPN.
- Degenerate BST
- An unbalanced BST, typically produced by inserting values in sorted order, that is effectively a linked list and degrades search to O(n).
Frequently asked questions
For every node in a BST, all values in its left subtree are less than the node's value, and all values in its right subtree are greater. This property holds at every node in the tree, not just at the root, and it allows searching to eliminate half the remaining tree at each comparison.
In-order traversal, which visits the left subtree, then the root, then the right subtree, outputs the values of a BST in ascending sorted order. This works only for a binary search tree that satisfies the ordering property; for a general binary tree the output will not be sorted.
No. BST search is O(log n) only for a balanced or near-balanced tree, where the height is approximately log₂ n. If values are inserted in sorted order the tree becomes a degenerate chain like a linked list, and in the worst case search degrades to O(n).
Generate revision on any topic you study
Type any topic you're studying and Aicademy generates a complete lesson, quiz, and flashcard set, personalised to your level.
Lessons on anything
Structured, level-matched lessons on any topic you study
Practice quizzes
Find out what you actually know before the exam does
Flashcard sets
Lock in key concepts with instant revision cards
Ask Aica
Stuck on something? Get a clear explanation, any time
Graphs
Hash Tables and Dictionaries
Related lessons
5 min
5 min
8 min
9 min