DSAVisualiseData Structures & Algorithms Studio
Hash Tables Hard

Library Store

A library store maps integer ISBNs to production years. Each bucket is a linked list, and the table doubles before an add when its load threshold is reached.
Load factor α0.00
Capacity 5Entries 0

Operations

Console
Try a scenario

Key stream

Complexity

Per operation
BestO(1)
AverageO(1 + α)
WorstO(n)

Expected constant time with a well-distributed hash.

SpaceO(n + m)

Diagram legend

Active bucketCollisionLinked entryMatch found

Hash pipeline

Java int
Input“98”
hashCode()—
& 0x7fffffff—
mod capacity—

LibraryStore bucket array

Books with colliding ISBN hashes are appended to the bucket’s linked list.

Memory view

Choose a scenario to follow the structure.

Why this worksConcept & common mistakes

A hash function chooses a bucket. Separate chaining stores every key assigned to that bucket in a linked chain. To insert, look up, or remove a key, compare the complete key at each node.

Worked example. Java hashes "11" to 1568 and "98" to 1823. Both have remainder 3 modulo 5. Inserting 98 → dog beside 11 → cat creates two distinct nodes in bucket 3.

  • A shared bucket is a collision, so compare the full key.
  • Replacing a value keeps the same node and entry count.
  • Removing the head must update the bucket pointer.
  • Resizing must recompute every key’s bucket index.

Algorithm code

Java
LibraryStore.java (pinned repository source)Step linked
Loading lesson source…
The highlighted line follows the current step.

Ready to begin

Press Play to see what happens.

Detailed execution
Snapshot 1 / 1
Comparisons 0 · Collisions 0

Understand your operation

Scroll to follow how your operation changes the table.

Explore detailed execution

Every row is a meaningful action from this stored run. Select one to inspect its saved state and optional Java reference.

    Ready for another operation?

    Return to the interactive table and try a different key.

    Back to the theater