Level 1: Bronze
A memorized definition. Not wrong, but it stops there.
It is a structure that finds values quickly by hashing the key.
3 stars If you are short on time, start with this one.
In one or two sentences
A hash function turns a key into an array position, so lookup is O(1) on average. When different keys land on the same spot, chaining or open addressing resolves the collision.
Say it out loud, or type it below. What you type never leaves this device.
A memorized definition. Not wrong, but it stops there.
It is a structure that finds values quickly by hashing the key.
Correct, but too broad or missing context.
A hash function turns the key into an array index, so lookup is O(1) on average. On a collision you either chain entries in a list in the same slot or probe for another empty slot.
Reaches principle, use and trade-off, with words that invite the next question.
Performance depends on how evenly the hash function spreads keys and on the load factor. Chaining hangs a list on each slot, and open addressing finds another empty slot. As the load factor rises, collisions grow and it slows, so at a threshold the table is enlarged and every key is rehashed. In the worst case everything lands in one slot and it is O(n). A hash table keeps no order, so for sorted or range queries a tree fits better.
These are likely next questions from an interviewer. Think of your answer first, then press the button.
1 / 3
How do chaining and open addressing differ?
Chaining keeps colliding entries in a list on one slot. Open addressing probes for another empty slot by a fixed rule. The latter needs no extra space but slows sharply at a high load factor.
2 / 3
When is a hash table O(n) in the worst case?
When all keys land in one slot, because of a poor hash function or an attacker who supplies colliding keys.
3 / 3
How do you choose between a hash table and a tree map?
Hash for many exact key lookups. Tree when you need sorted traversal or range queries.
This is a textbook level concept, so no outside source is listed.