

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 5
click for more info
Not enough gems
Cost: 6 gems
1: Hashmaps
incomplete
2: Hash Function
incomplete
3: Insert
incomplete
4: Get
incomplete
5: Hash Map Review
incomplete
6: Resizing
incomplete
7: Linear Probing
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Hashmaps are awesome. They are simple to use and have an average computational cost of O(1) for lookup, insertion, and deletion operations.
In Python, that means dictionaries. In Go, it means maps. In JavaScript, it means object literals. The point is, if you need an in-memory key-value store, hashmaps are awesome, and every language tends to have a built-in implementation.
O(1) for lookups, insertions, and deletions.Our toy hashmap:
def key_to_index(self, key: str) -> int:
sum = 0
for c in key:
sum += ord(c)
return sum % len(self.hashmap)
Has a few big problems, but at least it's valuable for understanding the concepts. Some of its big problems are: