TOPIC

Hashing

Compute where a key lives: h(k) → index. O(1) lookups, if collisions are tamed.

WHY DID WE NEED HASHING?

THE WALLArrays give O(1) access — but only by INDEX. Looking something up by KEY (a roll number, a username, a word) still means searching: O(n) in an array, O(log n) even in a balanced tree.

THE IDEADon't search for where a key is — COMPUTE it. A hash function h(k) turns the key itself into its slot: one arithmetic step replaces the entire search. The dictionary jumps straight to the page.

Python dicts, Java HashMaps, database indexes, caches, password stores — nearly every 'look it up by name' in computing is a hash table.

Choose a category