AlgoScope

Hash Map

Data structureintermediateHash Tables and Collision Handlingalso called dictionary, associative array

A hash table storing key-value pairs; the key picks the bucket and the value travels with it.

Decision · step 2 of 12Hash Map: Filling buckets, with collisions
01234

put 12 5: hash the key. 12 mod 5 = 2, so bucket 2 is the only place this key can be. It is empty.

Open in the player →or start at step 2

What you will see

Key and value travel together into the bucket.

How hash map works →

Cost

putO(1) expected
getO(1) expected
removeO(1) expected
SpaceO(n)

How you work with it here

play it through, step one change at a time, scrub to any step, run it on your own input, try operations in any order.

Screen readers: Each element is an accessibility element with position, value and state; structural changes are announced per step.

Reduced motion: Elements appear at their destination with a crossfade; no travel longer than the element's own size.

Before this

Taught by the same lesson

Hash Map covers these too, in the same run.