Hash Tables and Dictionaries
Aligned to the AQA 7517 specification
- Level
- Intermediate
- Reading time
- 6 min
- Published
- 13 June 2026
- Updated
- 1 July 2026
On this page
Key takeaways
- A hash table maps keys to values by using a hash function to compute an array index, giving insert, lookup and delete an average time complexity of O(1).
- Hash table operations are O(1) only on average; in the worst case where all keys collide to one slot, lookup is O(n).
- A collision is when two different keys hash to the same index; it can be resolved by chaining (a linked list per slot), linear probing (try the next slot), or quadratic probing (offsets +1², +2², +3², ...).
- Load factor is the number of entries divided by the table size; when it exceeds a threshold (around 0.7) rehashing doubles the table and reinserts every entry because the modulus has changed.
- A dictionary is an abstract data type of unique key-value pairs defined by its operations, and AQA requires knowing it can be implemented by a hash table (average O(1)) or a binary search tree (average O(log n), keys in sorted order).
How much of this have you taken in?
Quiz yourself on this section, free, no card needed.
Key terms
- Hash table
- A data structure that maps keys to values by using a hash function to compute an index into an underlying array.
- Hash function
- A function that takes a key and produces an integer index within the array bounds; it should be deterministic, uniform, and fast.
- Collision
- The situation where two different keys hash to the same index.
- Chaining
- A collision strategy where each slot holds a linked list of all entries that hash to it.
- Linear probing
- An open-addressing strategy that probes the next slots sequentially (+1, +2, +3, ...) until an empty slot is found.
- Quadratic probing
- An open-addressing strategy whose probe offset grows quadratically (+1², +2², +3², ...), reducing primary clustering.
- Primary clustering
- The bunching effect in linear probing where long filled runs form and slow future insertions.
- Load factor
- The number of entries divided by the table size; higher values mean more collisions and worse performance.
- Rehashing
- Doubling the table size and reinserting all entries when the load factor exceeds a threshold, since the modulus has changed.
- Dictionary
- An abstract data type storing an unordered collection of unique key-value pairs, also called a map or associative array.
- Abstract data type
- A type defined by its operations (interface) rather than its implementation.
Frequently asked questions
No. Hash table insert, lookup and delete are O(1) only on average, assuming a good hash function and a low load factor. In the worst case, where all keys collide to one slot, lookup degrades to O(n).
Both are open-addressing collision strategies. Linear probing tries the next slots sequentially (+1, +2, +3, ...), while quadratic probing uses growing offsets (+1², +2², +3², ...). Quadratic probing reduces primary clustering, the bunching of long filled runs in linear probing.
A dictionary is an abstract data type defined by its operations (get, set, delete, contains) on unique key-value pairs. A hash table is one implementation of it; a binary search tree is another. Describing a dictionary simply as a hash table confuses the abstraction with one implementation.
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
Binary Search Trees
Vectors
Related lessons
5 min
8 min