Hash Functions: What "Random" Means When It Has to Be Deterministic
A Ruby Hash gives you O(1) lookup. So does Python's dict, Java's HashMap, Go's map. They all do the same trick: take whatever key you give them — a string, a tuple, an arbitrary o…
Hashing and Advanced Linear Structures covers: Hash Functions, Hash Tables, Open Addressing in Practice, Bloom Filters, Skip Lists and Union-Find. Year 1, Quarter 2. Includes 15 exercises and 2 projects.
This course unlocks once you've finished its prerequisite. Open prerequisite →
A Ruby Hash gives you O(1) lookup. So does Python's dict, Java's HashMap, Go's map. They all do the same trick: take whatever key you give them — a string, a tuple, an arbitrary o…
A hash table is two things glued together: an array of buckets, and a hash function that picks which bucket a key belongs to. Both pieces are simple. The combination earns you O(1…
The chained hash table from the last lesson works, but it has one cost that doesn't show up in the Big O analysis: it allocates a linked-list node per entry, and those nodes are s…
Every data structure you've built so far has been exact: ask "does this set contain x?" and the answer is yes or no, always correct. A Bloom filter is the first data structure on …
Two structures end this quarter's data-structures tour: skip lists (a probabilistic alternative to balanced trees, used by Redis for sorted sets) and union-find (a tiny structure …
- [ ] Two Sum (#1) — NC/LC — Hash map for complement lookup in O(n) - [ ] Valid Anagram (#242) — NC/LC — Character frequency counting with hash - [ ] Contains Duplicate (#217) — N…
- [ ] Group Anagrams (#49) — NC/LC — Hash map with sorted-string keys - [ ] Top K Frequent Elements (#347) — NC/LC — Hash map + bucket sort or heap - [ ] Longest Consecutive Seque…
- [ ] LRU Cache (#146) — NC/LC — Hash map + doubly-linked list for O(1) get/put - [ ] Find the Duplicate Number (#287) — NC/LC — Floyd's cycle detection on array indices
- [ ] Build a spell checker in Ruby — load a dictionary into a hash table, implement Levenshtein distance for suggestions, add a Bloom filter for fast "definitely not in dictionar…
Build MyHash in Ruby using open addressing with linear probing. Implement []=, [], delete, key?, each, keys, values, automatic resizing at 75% load factor. Benchmark against Ruby'…
Generate random mazes using Union-Find (Kruskal's algorithm for random spanning trees on a grid). Then solve the maze using BFS. Output the maze and solution path as ASCII art. In…
- [ ] How does a hash table work? Explain hash functions, buckets, and collision resolution. - [ ] What is the difference between chaining and open addressing (linear probing)? - …
- [ ] Course 2.1 knowledge check passed - [ ] Course 2.2 knowledge check passed - [ ] Course 2.3 knowledge check passed - [ ] Database Index Engine capstone completed
13 lessons. Read in order; spiral back when you need to. By the end you'll have used the core ideas twice — once on the abstract, once on something you'll meet at work next week.