Hash tables + B4 cumulative Paper 2 checkpoint
Abstract data types separate what operations mean from how they are implemented, helping you choose structures by behaviour and trade-offs.
What you need to be able to do
- ExplainThe core principles of ADTs
- RetrieveReconnect today’s new material to previously taught content from this topic.
Rapid Recall Deck
Say the answer aloud before flipping. Mark secure knowledge quickly and spend time on the gaps.
- What is the purpose of a hash function in a hash table?: It transforms a key into an index/location used to place or find the associated data.
- What is a collision in hashing?: Two different keys produce the same table location/index.
- What are two common ways to resolve hash collisions?: Separate chaining stores multiple entries at a location; open addressing searches for another available location in the table.
- What is a hash table's load factor?: A measure of how full the table is, commonly the number of stored entries divided by the number of table slots.
- Why can a high load factor hurt hash-table performance?: More entries competing for limited locations generally increases collisions and the work needed to resolve them.
- Which Java and Python structures provide hash-based maps and sets?: Java: HashMap and HashSet. Python: dict and set.
- What three linked-list forms must you distinguish?: Singly linked, doubly linked, and circular linked lists.
- What four core operations apply to linked lists?: Insertion, deletion, traversal, and search.
- What ordering idea makes a binary search tree searchable?: Each node separates values into ordered left and right subtrees according to the chosen comparison rule.
- What two properties distinguish a set ADT?: Its elements are unique and the set is unordered.
Core knowledge and application
The core principles of ADTs
Abstract data types separate what operations mean from how they are implemented, helping you choose structures by behaviour and trade-offs.
Explain it without notes
Explain: The core principles of ADTs in the context of a system that needs efficient insertion, search and set membership.
- High-level description of data structures and their associated operations and purpose
- The underlying mechanics of hash tables, including hashing functions, collision resolution strategies and load factors
- The underlying mechanics of sets to store and manage data
- HashMap and HashSet in Java; dict and set in Python
Programming checkpoint
prices = {"pen": 2.5, "notebook": 5.0}
prices["marker"] = 3.0
print(prices.get("pen"))HashMap<String, Double> prices = new HashMap<>();
prices.put("pen", 2.5);
prices.put("notebook", 5.0);
prices.put("marker", 3.0);
System.out.println(prices.get("pen"));Modify it
Change one condition, input or operation so the program solves a slightly different problem. Predict the effect before editing.
Hashing, collisions and load factor
Suppose index = key mod 5.
All three keys target bucket 2: this is a collision.
Separate chaining
Bucket 2 stores a small collection/list of entries: [12, 7, 22].
Open addressing
If bucket 2 is occupied, probe another bucket according to the chosen strategy until an available position is found.
stored entries / number of buckets. As the table becomes crowded, collisions and probe/chain costs typically increase, so resizing/rehashing may be useful.Transfer to a new scenario
- High-level description of data structures and their associated operations and purpose
- The underlying mechanics of hash tables, including hashing functions, collision resolution strategies and load factors
Paper 2 practice
- Explain: The core principles of ADTs in the context of a system that needs efficient insertion, search and set membership.
Finish the learning cycle
IA — main task
Continue Criterion D development. Keep code readable, record meaningful implementation decisions, and maintain testing/evidence notes as you work.
Syllabus — short
Complete one targeted Paper 2/Paper 1 retrieval task from today’s lesson.