UnorderedMap Visualizer

Hash table using separate chaining for collision resolution

6
Buckets
0
Total Entries
0
Avg Chain Length
0
Max Chain Length

Ready for UnorderedMap operations

Hash Function with Separate Chaining

hash(key) = (Σ key[i] × 31) % 6
Collisions are resolved by chaining entries in linked lists

Hash Table with Separate Chaining

[0]
0 items
Empty bucket
[1]
0 items
Empty bucket
[2]
0 items
Empty bucket
[3]
0 items
Empty bucket
[4]
0 items
Empty bucket
[5]
0 items
Empty bucket

Chain Length Distribution

B0
B1
B2
B3
B4
B5
Height represents chain length in each bucket

UnorderedMap Operations:

Basic Operations:

  • insert/put(key, value): Add or update key-value pair
  • find/get(key): Retrieve value for given key
  • erase/remove(key): Delete key-value pair
  • count/contains(key): Check if key exists

Collision Handling:

  • Separate Chaining: Each bucket is a linked list
  • Chain Traversal: Linear search within each chain

Characteristics:

  • Average Time: O(1) for all operations
  • Worst Case: O(n) if all keys hash to same bucket
  • Space: O(n) for entries + O(b) for buckets
  • No Ordering: Keys are not stored in any particular order
  • Dynamic Resizing: Can resize to maintain performance
  • Use Cases: Caches, frequency counting, graph adjacency lists
Separate Chaining vs Linear Probing: Separate chaining handles collisions by storing multiple entries in each bucket using linked lists, while linear probing finds the next empty slot. Chaining never runs out of space but uses extra memory for pointers.