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 keyread by indexinsert in middletake the maxkeep in order
ArrayO(n)O(1)O(n)O(n)sort first
Linked listO(n)O(n)O(1)O(n)no
Hash mapO(1)noO(1)O(n)no
Balanced treeO(log n)noO(log n)O(log n)yes
HeapO(n)noO(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…