Two objects with the same hashCode must be equal.
- Equal objects must have equal hash codes, not the reverse.
Hash functions and Java’s hashCode conventions, modular hashing, the uniform hashing assumption, collisions, separate chaining, linear probing, resizing and deletion, and the cost summary.
Every original slide is shown unchanged. Yellow marks on a slide point to a numbered note: hover or tap a mark to jump to its note, and hover a note to see its marks. Questions tagged Past exam appeared on a real paper; Prediction questions are likely angles, not confirmed. Pick an answer to each question: a wrong pick tells you why it is wrong, so you can try again.
Two objects with the same hashCode must be equal.
Separate chaining: each slot holds a linked list of the keys that hash there.
In separate chaining, colliding keys are stored:
With linear probing, a key that hashes to a full slot goes to:
Keep the table at most about half full for linear probing (α ≤ ½).
Hashing: constant expected time for search/insert/delete; no ordered operations.
Expected cost of search in a well-sized hash table: