The whole toolbox at once
Choosing the Right Tool
The analogy
You now know the shapes. Need instant lookup by name? Hash map. Need order and range queries? Sorted array or tree. Constantly inserting in the middle? Linked list. The skill is not memorising the table — it is asking "what will this do when the data is a hundred times bigger?"
Visualizer
The whole toolbox
step 1 / 7| lookup by key | read by index | insert in middle | take the max | keep in order | |
|---|---|---|---|---|---|
| Array | O(n) | O(1) | O(n) | O(n) | sort first |
| Linked list | O(n) | O(n) | O(1) | O(n) | no |
| Hash map | O(1) | no | O(1) | O(n) | no |
| Balanced tree | O(log n) | no | O(log n) | O(log n) | yes |
| Heap | O(n) | no | O(log n) | O(1) | no |
The whole toolbox on one grid. You are never memorising this — you are learning to read down a column.
# pick by the operation you do MOST users[user_id] # dict -> O(1) for row in rows: # list -> O(1) index heapq.heappop(tasks) # heap -> O(1) min bisect.insort(scores, s) # sorted list -> order deque.popleft() # queue -> O(1) both ends
Check yourself
You need lookup by ID and never need order. Use…