Hash Table
Hash table with configurable collision resolution strategies
Collision Resolution Method
Current Method: Linear Probing
Formula: h(k, i) = (k % 10 + i) % 10
Insert Values
| Index | Value |
|---|---|
| 0 | - |
| 1 | - |
| 2 | - |
| 3 | - |
| 4 | - |
| 5 | - |
| 6 | - |
| 7 | - |
| 8 | - |
| 9 | - |
How Linear Probing Works
Hash Function: h(k) = k % 10
Collision Resolution: If the computed index is occupied, check the next index sequentially (i = 0, 1, 2, ...), wrapping around to 0 after index 9.
Example: Inserting 21 → h(21) = 1. Inserting 31 → h(31) = 1, but index 1 is occupied, so try index 2.
Time Complexity
| Operation | Average | Worst Case |
|---|---|---|
| Insert | O(1) | O(n) |
| Search | O(1) | O(n) |
| Delete | O(1) | O(n) |
Note: Double hashing generally provides better distribution than linear or quadratic probing, reducing clustering and improving average-case performance in practice.