HashMap
Hashing, collision chains, and manual step-through bucket operations
HashMap Basics
Bucket Chainsbucket = hash(key) % 5
Bucket 0 already contains ab:10 and ba:20 so the collision chain is visible before you start.
[0]
ab:10→
ba:20
[1]
ac:30
[2]
ad:40
[3]
ae:50
[4]
af:60
HashMap State
Operation
idle
Key
—
Value
—
Hash Sum
—
Bucket Index
—
Chain Entry
—
Chain Length
—
Status / Result
Idle
→ hash(key) = sum(char codes) % 5
HashMap Basics
This demo uses a fixed capacity of 5 and the formula hash(key) = sum(char codes) % 5. The keys ab and ba both land in bucket 0 because their character sums are the same.
Collisions are handled with chaining, so multiple entries can live in the same bucket as a visible ordered chain.
Select an operation, then press Next Step to walk through hashing, collision detection, lookup comparisons, or deletion one state at a time.
Complexity
Hash
Time:O(k)
Space:O(1)
Insert
Time:O(1) avg / O(n) worst
Space:O(n)
Get
Time:O(1) avg / O(n) worst
Space:O(n)
Delete
Time:O(1) avg / O(n) worst
Space:O(n)