This chapter collects all the essential reference material from the tutorial into one place. Use these tables as a quick cheatsheet when solving problems or preparing for interviews.
Bookmark this page. It compresses 14 chapters of DSA knowledge into a single-page quick guide you can refer to anytime.
Data Structures — Operations & Complexities
Data Structure
Access
Search
Insert
Delete
Space
Array
O(1)
O(n)
O(n)
O(n)
O(n)
Linked List (Singly)
O(n)
O(n)
O(1)
O(1)
O(n)
Stack (LIFO)
O(n)
O(n)
O(1)
O(1)
O(n)
Queue (FIFO)
O(n)
O(n)
O(1)
O(1)
O(n)
Deque
O(n)
O(n)
O(1)
O(1)
O(n)
Hash Table
N/A
O(1)*
O(1)*
O(1)*
O(n)
BST (balanced)
O(log n)
O(log n)
O(log n)
O(log n)
O(n)
Heap (Min/Max)
O(1)
O(n)
O(log n)
O(log n)
O(n)
Graph (adjacency list)
O(1)
O(V + E)
O(1)
O(E)
O(V + E)
Trie (prefix tree)
O(k)
O(k)
O(k)
O(k)
O(n * k)
* Average case for hash tables. Worst case: O(n) due to collisions.
# Binary search
lo, hi = 0, len(arr) - 1
while lo <= hi:
mid = (lo + hi) // 2
if arr[mid] == target: break
elif arr[mid] < target: lo = mid + 1
else: hi = mid - 1
# Tree traversals
def inorder(node): inorder(node.left); print(node); inorder(node.right)
def preorder(node): print(node); preorder(node.left); preorder(node.right)
def postorder(node): postorder(node.left); postorder(node.right); print(node)
# BFS
queue = [start]; visited = {start}
while queue:
u = queue.pop(0)
for v in graph[u]:
if v not in visited: visited.add(v); queue.append(v)
# DFS recursion
def dfs(u):
visited.add(u)
for v in graph[u]:
if v not in visited: dfs(v)
# DSU find with path compression
def find(x):
if parent[x] != x:
parent[x] = find(parent[x])
return parent[x]
This reference sheet covers roughly 90% of what you will encounter in a DSA coding interview. Master these patterns and you will be well prepared.
Practice Task
Pick any three algorithms from the reference tables above that you feel least confident about. Implement them from scratch without looking at any reference. Then compare your implementation to the versions in the earlier chapters. Repeat until you can implement all of them from memory.