Hash Explorer
▶ DRILLA hash function takes an input of any size — a number, a string, a file — and deterministically maps it to a fixed-size output. Feed it the same input twice and you get the same result every time; change the input by a single character and the result looks completely unrelated.
Not every hash chases the same goal, though. A cheap hash likek % 8 only needs to be fast and spread keys evenly — it's fine, even desirable, for it to stay simple and predictable. A cryptographic hashlike MD5 or SHA-256 has a much harder job: it must be infeasible to reverse, infeasible to find two inputs that collide, and wildly sensitive to the smallest change in input. That extra rigor is what makes it too slow for a hash table, but trustworthy enough for passwords and integrity checks.
A hash table puts the cheap kind to work: it maps keys to array slots via a hash function, giving average O(1) insert, search, and delete. The interesting part is what happens when two keys land on the same slot. Insert, search, and delete keys below, and switch between separate chaining and open addressing to see two different answers to that collision problem.
The table above uses k % 8 — a toy hash that's easy to trace by hand. Real hash functions are designed so that the output looks unpredictable and changes completely for even a one-character change in the input (the "avalanche effect"). Type something below and compare algorithms: