- Hashing: compute an array index from the key; handle collisions.
- Java: if x.equals(y) then x.hashCode() == y.hashCode().
🎯 How this can come up · 1 question
Two objects with the same hashCode must be equal.
False. Equal objects must have equal hash codes, not the reverse.
- Modular hashing: (key.hashCode() & 0x7fffffff) % M.
- Collision: two keys hash to the same index.
- Separate chaining: each slot holds a linked list of the keys that hash there.
🎯 How this can come up · 1 question
In separate chaining, colliding keys are stored:
Correct: In a linked list at that index.
- Open addressing / linear probing: on collision, try the next slot (i + 1) until empty.
🎯 How this can come up · 1 question
With linear probing, a key that hashes to a full slot goes to:
Correct: The next free slot.
- Keep the table at most about half full for linear probing (α ≤ ½).
- Hashing: constant expected time for search/insert/delete; no ordered operations.
🎯 How this can come up · 1 question
Expected cost of search in a well-sized hash table:
Correct: O(1).
No slides match this filter.