← Back to Tutorials Chapter 15

References & Quick Guide

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.
DSA reference sheet

Data Structures — Operations & Complexities

Data StructureAccessSearchInsertDeleteSpace
ArrayO(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)
DequeO(n)O(n)O(1)O(1)O(n)
Hash TableN/AO(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.

Sorting Algorithms Reference

AlgorithmBestAverageWorstSpaceStable
Bubble SortO(n)O(n²)O(n²)O(1)Yes
Selection SortO(n²)O(n²)O(n²)O(1)No
Insertion SortO(n)O(n²)O(n²)O(1)Yes
Merge SortO(n log n)O(n log n)O(n log n)O(n)Yes
Quick SortO(n log n)O(n log n)O(n²)O(log n)No
Heap SortO(n log n)O(n log n)O(n log n)O(1)No
Counting SortO(n + k)O(n + k)O(n + k)O(k)Yes
Radix SortO(d * (n + k))O(d * (n + k))O(d * (n + k))O(n + k)Yes

Searching Algorithms Reference

AlgorithmData StructureTime ComplexitySpace Complexity
Linear SearchArray / ListO(n)O(1)
Binary SearchSorted ArrayO(log n)O(1)
BFS (Breadth-First Search)Graph / TreeO(V + E)O(V)
DFS (Depth-First Search)Graph / TreeO(V + E)O(V)
Dijkstra (SSSP)Graph (non-negative weights)O((V + E) log V)O(V)
Bellman-Ford (SSSP)Graph (allows negative weights)O(V * E)O(V)
Floyd-Warshall (APSP)Graph (allows negative weights)O(V³)O(V²)
A* SearchGraph with heuristicO(E) (w/ good heuristic)O(V)
Prim's Algorithm (MST)Graph (undirected)O(E log V)O(V)
Kruskal's Algorithm (MST)Graph (undirected)O(E log E)O(V)
Ford-Fulkerson (Max Flow)Flow NetworkO(E * |f|)O(V)
Edmonds-Karp (Max Flow)Flow NetworkO(V * E²)O(V)

Graph Algorithms Reference

ProblemAlgorithmsKey Idea
Shortest Path (unweighted)BFSQueue, O(V + E)
Shortest Path (non-negative)DijkstraPriority queue, greedy
Shortest Path (negative edges)Bellman-FordRelax V-1 times, detect negative cycles
All-Pairs Shortest PathFloyd-WarshallDP over intermediate vertices
Minimum Spanning TreePrim / KruskalGreedy: vertex vs edge based
Maximum FlowFord-Fulkerson / Edmonds-KarpAugmenting paths, residual graph
Topological SortDFS / Kahn'sOrdering DAG vertices
Cycle Detection (directed)DFS with colors / Kahn'sBack edges or in-degree tracking
Bipartite CheckBFS with colors2-coloring
Strongly Connected ComponentsKosaraju / TarjanDFS + transpose / low-link values

Dynamic Programming Patterns

Quick Guide Cheatsheet

Big-O Complexity Classes

O(1)       < O(log n)   < O(n)     < O(n log n)  < O(n²)     < O(2ⁿ)     < O(n!)
constant   logarithmic   linear    linearithmic   quadratic   exponential   factorial

Common Recurrence Solutions

T(n) = 2T(n/2) + O(n)      → O(n log n)   (Merge Sort)
T(n) = T(n-1) + O(1)        → O(n)         (Linear recursion)
T(n) = T(n-1) + T(n-2)      → O(2ⁿ)        (Naive Fibonacci)
T(n) = 2T(n-1) + O(1)       → O(2ⁿ)        (Subset generation)

Python Snippets for Quick Reference

# 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.