Hashing Visualizer
Hash Tables
Watch keys map into buckets with modulo hashing, collisions, chain traversal, and live average versus worst-case complexity.
O(n)
map: value -> frequencyactive key: 18
Bucket 0
empty
Bucket 1
empty
Bucket 2
empty
Bucket 3
empty
Bucket 4
empty
Bucket 5
empty
Bucket 6
empty
Time
O(n)
Space
O(n)
Step Note
Count how many times each value appears.
function countFrequencies(values: number[]) {
const counts = new Map<number, number>()
for (const value of values) {
counts.set(value, (counts.get(value) ?? 0) + 1)
}
return counts
}