Algorithms & Data Structures
Sorting, searching, graphs, trees, recursion and dynamic programming - animated step by step.
About this track
Algorithms are the one part of computer science where an animation is obviously better than prose: the whole point is what changes on each step. This is the largest track on VizLearn, running from Big-O notation through the sorts, the searches, linked structures, trees, heaps, graphs, and the recursion-and-memoisation family.
Each page runs the algorithm at your pace, highlighting the comparison or the pointer move that just happened, with the complexity written out underneath so the cost is attached to the behaviour rather than memorised separately.
Every page reports the operation count as it runs, so the complexity written at the top is something you can check rather than something you have to take on trust - and the difference between O(n) and O(log n) becomes a number you watched accumulate.
What you will be able to do
- Derive a complexity rather than memorise it, by counting the work each step does.
- Choose a sorting algorithm from the constraints - stability, memory, and how sorted the input already is.
- Explain why binary search needs sorted data, and what breaks silently when it is not.
- Pick between breadth-first and depth-first search from what the problem is asking.
- Recognise when a hash table turns an accidental O(n squared) loop into a linear one.
How the track is ordered
Big-O comes first, because every page afterwards refers back to it. Then the linear structures - arrays, linked lists, stacks and queues - followed by searching and sorting, which is where complexity differences first become dramatic. Trees, heaps and hash tables come next, then graphs and their traversals, and finally the strategies that cut across all of them: recursion, divide and conquer, greedy methods, dynamic programming and backtracking. No prior computer science is assumed, though the Python pages in this track help if you want to run the code yourself.
Where this leads
These are the foundations interviews test and the reason some machine learning methods scale and others do not. The databases track applies the same thinking to indexes and query plans, where a B-tree and a query execution order are exactly the ideas from this track under different names.
All 41 modules, in teaching order
- 01Big-O Notation and Time ComplexityCompare O(1) through O(2^n) on the same input and see why constants vanish and growth rate is all that matters at scale.
- 02Python List LabIndex, slice, append and mutate Python lists interactively, and see how the underlying dynamic array grows as you go.
- 03Python String LabSlice, index, join and format Python strings interactively, and see how immutability shapes what each operation does.
- 04Python Dictionary LabInsert, look up and delete key-value pairs in a Python dictionary, and see how hashing makes each operation instant.
- 05Linear SearchStep through an array one element at a time and see exactly when brute-force scanning is genuinely the right choice.
- 06Binary SearchHalve the search space with every comparison and watch binary search locate a target in a sorted array in log n steps.
- 07Interpolation SearchEstimate where a value should sit instead of always splitting the middle, the way you open a phone book near the S pages.
- 08Fibonacci SearchDivide a sorted array using Fibonacci numbers rather than midpoints, avoiding the division binary search relies on.
- 09Bubble SortWatch adjacent pairs compare and swap, sending the largest value bubbling to the end on every pass through the array.
- 10Selection SortScan for the smallest remaining value and swap it into place, one position at a time, until the whole array is sorted.
- 11Insertion SortBuild a sorted section one element at a time and watch each new value shift left into the position where it belongs.
- 12Recursion and the Call StackWatch each recursive call push a frame onto the call stack, and see the values computed on the way back up, not the way down.
- 13Divide and ConquerSplit a problem in half, recurse, combine — and see how halving at each level gives merge sort its O(n log n) guarantee.
- 14Merge SortSplit an array down to single elements and watch merge sort combine sorted halves back together in n log n time.
- 15Quick SortPick a pivot, partition around it, then recurse, and see why the pivot choice decides whether quick sort flies or crawls.
- 16Counting SortSort integers without a single comparison by tallying how often each value occurs, then rebuilding the array in order.
- 17Radix SortSort integers digit by digit with zero comparisons and beat the O(n log n) lower bound that comparison-based sorts cannot escape.
- 18Stacks (LIFO)Push, pop and peek at the top of a LIFO structure, and see how the call stack, bracket matching and DFS all share this idea.
- 19Queues (FIFO)Add at the back, remove from the front — FIFO ordering — and see how swapping a stack for a queue turns DFS into BFS.
- 20Linked ListsStore elements in nodes linked by pointers and trade O(1) random access for O(1) insertion at any known position.
- 21Hash Tables and HashingHash a key into an array index for O(1) lookup and see how collisions, load factor and resizing keep the constant-time promise.
- 22Binary Search TreesInsert, search and delete in a BST and watch it degenerate into a linked list when values arrive sorted — the case balance fixes.
- 23Heaps and Priority QueuesMaintain a complete binary tree where the smallest element is always at the root, with O(log n) insert and extract-min.
- 24Heap SortBuild a max-heap and extract the largest element n times for a guaranteed O(n log n) sort — no worst case, no extra memory.
- 25Trie (Prefix Tree)Store strings as paths through a tree so words sharing a prefix share those nodes, making autocomplete an O(L) walk.
- 26Union-Find (Disjoint Set)Merge and query disjoint sets in near-constant time with union by rank and path compression — the engine inside Kruskal's MST.
- 27Graph RepresentationsStore a graph as an adjacency matrix, adjacency list or edge list and see how the choice changes the cost of every algorithm on it.
- 28Breadth First SearchTraverse a tree level by level using a queue, and see why BFS finds the shortest path in an unweighted graph by construction.
- 29Depth First SearchFollow depth-first search as far down one branch as it goes, then watch it backtrack and take the next unexplored edge.
- 30Cycle DetectionRun Floyd's tortoise-and-hare algorithm on a linked list and find the cycle entry point in O(n) time and O(1) space.
- 31Topological SortOrder a directed graph so every edge points forward, and detect when a cycle makes that ordering impossible.
- 32Dijkstra's AlgorithmWatch Dijkstra's algorithm settle nodes in order of distance and build the shortest path across a weighted graph.
- 33Bellman-Ford and Negative WeightsRelax every edge V-1 times to find shortest paths with negative weights, then run one extra pass to detect negative cycles.
- 34A* Pathfinding AlgorithmWatch A* combine real distance with a heuristic estimate to reach the goal while exploring far fewer nodes than Dijkstra.
- 35Minimum Spanning TreeConnect every vertex at minimum total cost with Kruskal's edge-sorting and Prim's vertex-growing approaches side by side.
- 36Two PointersMove two indices through a sorted array in one pass and replace an O(n-squared) nested loop with O(n) and no extra space.
- 37Sliding WindowSlide a fixed or variable-size window across an array, updating a running total to replace an O(n*k) nested loop with O(n).
- 38Greedy AlgorithmsTake the locally best option at each step and see when that greedy choice is provably optimal — and when it quietly fails.
- 39Backtracking Search MethodWatch backtracking commit to a path, hit a dead end, and unwind to the last decision point until the puzzle resolves.
- 40Dynamic ProgrammingCache subproblem results so they are solved once, not millions of times, and watch Fibonacci drop from exponential to linear.
- 41KMP String MatchingBuild a failure function from the pattern and scan the text in O(n + m) total, never re-reading a character after a mismatch.