Data Structures

Hash Table in C++ — Interactive Demo

Linear Probing (open addressing)

🗄 Hash table table[10]  EMPTY = -1 · indices 0–9

starting slot h(key) collision, probing inserted occupied / miss h(key)=key%10 · on collision: index=(index+1)%10

💬 Current step

💻 Code: HashTable (linear probing)

📐 Formulas

Hash function:  h(key) = key % TABLE_SIZE  (TABLE_SIZE = 10, indices 0–9)
Linear probing:  index = (index + 1) % TABLE_SIZE ← scan the next slot on collision (wrap from 9 back to 0)
Search stop rule:  an EMPTY slot means the key is absent; if we loop back to start, it is absent too
Speed
Shortcuts: Space play/pause · ←→ step · R reset · E result