Data Structures & Algorithms
Big-O, sorting (bubble, selection, insertion, merge, quick), binary search, linked lists, stacks, queues, hash tables, search trees and heaps — in real Java that compiles and runs in the Arena IDE, with a Visualize tab that animates every algorithm step by step.
- Step 1
Big-O notation
Measure growth, not seconds
Start lesson - Step 2
Arrays & memory
Index O(1), search O(n), insert O(n)
Start lesson - Step 3
Bubble sort
O(n²) time · O(1) space · stable
Start lesson - Step 4
Selection sort
O(n²) time · O(1) space · ~n swaps
Start lesson - Step 5
Insertion sort
O(n²) worst · O(n) nearly-sorted · stable
Start lesson - Step 6
Merge sort
O(n log n) time · O(n) space · stable
Start lesson - Step 7
Quick sort
O(n log n) avg · O(n²) worst · in-place
Start lesson - Step 8
Binary search
O(log n) — requires a sorted array
Start lesson - Step 9
Linked lists
Insert/remove at head O(1) · index O(n)
Start lesson - Step 10
Stacks & queues
Push/pop/enqueue/dequeue O(1)
Start lesson - Step 11
Hash tables
Average O(1) insert / lookup / delete
Start lesson - Step 12
Binary search trees
O(log n) balanced · O(n) worst (skewed)
Start lesson - Step 13
Heaps & priority queues
Peek O(1) · insert/remove O(log n)
Start lesson - Step 14
Recursion & the call stack
One frame per call · O(depth) memory
Start lesson - Step 15
Two pointers
O(n) time · O(1) space
Start lesson - Step 16
Sliding window
O(n) time · O(1) or O(k) space
Start lesson - Step 17
Prefix sums & difference arrays
O(n) build · O(1) per query
Start lesson - Step 18
Backtracking
Exponential by nature · prune to survive
Start lesson - Step 19
Graphs & how to store them
Adjacency list O(V+E) space · matrix O(V²)
Start lesson - Step 20
Breadth-first search
O(V + E) · shortest path when edges are unweighted
Start lesson - Step 21
Depth-first search
O(V + E) · components, cycles, ordering
Start lesson - Step 22
Topological sort
O(V + E) · order a DAG by dependency
Start lesson - Step 23
Union-Find (disjoint sets)
Near O(1) amortised per operation
Start lesson - Step 24
Dynamic programming — memo to table
Exponential to polynomial by remembering
Start lesson - Step 25
DP II — knapsack & grids
O(n·W) time · O(W) space compressed
Start lesson - Step 26
Greedy algorithms
Usually O(n log n) — the sort dominates
Start lesson - Step 27
Tries (prefix trees)
O(L) per word · shares prefixes
Start lesson - Step 28
Bit manipulation
O(1) per operation · O(32) per int
Start lesson - Step 29
Sorting without comparisons
O(n + k) counting · O(d(n + b)) radix
Start lesson - Step 30
String matching — KMP
O(n + m) · never re-reads the text
Start lesson - Step 31
Comparators & sorting objects
O(n log n) comparisons · TimSort is stable, dual-pivot quicksort is not
Start lesson - Step 32
Matrices & grids
O(rows × cols) per traversal · in-place rotate is O(1) extra
Start lesson - Step 33
Monotonic stacks
O(n) — every index is pushed once and popped at most once
Start lesson - Step 34
Intervals
O(n log n) — the sort dominates, every sweep after it is one pass
Start lesson - Step 35
Binary search on the answer
O(n log(hi - lo)) — one O(n) feasibility check per halving
Start lesson - Step 36
Quickselect
O(n) average · O(n^2) worst · O(1) extra space
Start lesson - Step 37
Dijkstra's shortest path
O((V+E) log V) with a binary heap
Start lesson - Step 38
Minimum spanning trees
Kruskal O(E log E) · Prim O((V+E) log V)
Start lesson - Step 39
DP on strings
O(m·n) time · O(min(m,n)) space once the table is rolled
Start lesson - Step 40
Fenwick trees (BIT)
Update and prefix query both O(log n) · O(n) memory
Start lesson - Step 41
Number theory essentials
gcd O(log min(a,b)) · sieve O(n log log n) · modular power O(log e)
Start lesson - Step 42
Designing an LRU cache
O(1) get and put · O(capacity) memory
Start lesson - Step 43
Kadane's algorithm — maximum subarray
O(n) time · O(1) space · one comparison per element
Start lesson - Step 44
Heap sort — sorting in place with a heap
O(n log n) worst case · O(1) extra space · build is O(n) · not stable
Start lesson - Step 45
Floyd's cycle detection — tortoise and hare
O(n) time · O(1) space · finds the cycle, its entrance and its length
Start lesson - Step 46
Rabin–Karp — rolling hashes
O(n + m) expected · O(n·m) worst case · O(1) extra space
Start lesson - Step 47
Palindromes — expanding around centres
O(n²) time, O(1) space — 2n−1 centres, each expanded once
Start lesson - Step 48
Bellman–Ford — shortest paths with negative edges
O(V·E) time · O(V) space · negative edges allowed, negative cycles detected
Start lesson - Step 49
Floyd–Warshall — every pair at once
O(V³) time · O(V²) space · negative edges allowed
Start lesson - Step 50
Self-balancing trees — rotations
O(log n) insert, delete and search — guaranteed, not hoped for
Start lesson - Step 51
Segment trees — range queries that survive updates
Build O(n) · query and update O(log n) · one int[] of 4n
Start lesson - Step 52
Huffman coding — the shortest possible codes
Build O(n log n) in the alphabet · encode O(bits out) · within 1 bit of entropy
Start lesson - Step 53
Strongly connected components — Kosaraju
O(V + E) time · two DFS passes over a graph and its transpose
Start lesson - Step 54
Shuffling and sampling — Fisher–Yates and reservoir
Shuffle O(n) time · O(1) space · reservoir O(n) time · O(k) space, one pass
Start lesson - Step 55
Choosing the right structure
The skill every other lesson feeds
Start lesson