AlgoViz
🧩 Watch every algorithm move

Data Structures & Algorithms

The core toolkit, built from zero — start with what a variable even is, then climb through searching, sorting, hashing, trees, graphs, and dynamic programming. Every lesson is a live animation you can run, scrub, and feed your own input. The full dependency map lives on /map.

Foundations

  1. 1

    What is a Variable?

    EasyArray▶ animated

    The smallest idea in all of code: a labeled box that holds one value — and that value can change.

  2. 2

    What is an Array?

    EasyArray▶ animated

    Before any algorithm: an array is a row of numbered boxes. Meet the index and the value.

  3. 3

    One Box at a Time

    EasyArray▶ animated

    Why searching is even a problem: a computer can't see all the boxes at once — it opens them one by one.

  4. 4

    Bits & Binary

    EasyArray▶ animated

    Numbers are secretly rows of on/off light switches — and flipping them lets you do clever tricks like erasing duplicates with XOR.

Searching

  1. 5

    Linear Search

    EasyArray▶ animated

    Check each element one by one until you find the target. The O(n) baseline.

  2. 6

    What is Sorted?

    EasyArray▶ animated

    'Sorted' isn't just 'tidy' — it's a promise: each box is never smaller than the one before it.

  3. 7

    Binary Search

    EasyArray▶ animated

    Find a target in a sorted array by repeatedly halving the search space.

Arrays & strings

  1. 8

    Two Pointers

    EasyArray▶ animated

    Find a pair summing to a target in a sorted array by converging two pointers.

  2. 9

    Sliding Window

    MediumArray▶ animated

    Glide a contiguous window across an array or string, updating the answer as it moves — one pass instead of re-checking every range.

  3. 10

    Prefix Sums

    EasyArray▶ animated

    Precompute running totals once, then answer any range-sum in O(1) with a single subtraction.

Hashing

  1. 11

    Hashing (Hash Set)

    EasyGrid / DP▶ animated

    Store values in buckets by value % size for O(1) average lookup.

  2. 12

    Hash Map

    MediumGrid / DP▶ animated

    Store key→value pairs and fetch any of them almost instantly — by letting a hash function pick the slot.

Stacks, queues & lists

  1. 13

    Stack & Queue

    EasyArray▶ animated

    LIFO vs FIFO: a stack pops the newest, a queue dequeues the oldest.

  2. 14

    Monotonic Stack: Next Greater Element

    MediumArray▶ animated

    Keep a stack that stays sorted in one direction to find each number's next-greater element in a single O(n) pass.

  3. 15

    Linked List Traversal

    EasyArray▶ animated

    Follow next pointers from head to null — a pointer is a reference to a node.

  4. 16

    KMP String Matching

    HardArray▶ animated

    Find a pattern inside a text without ever re-checking characters you already matched, using the LPS table.

  5. 17

    Greedy: Activity Selection

    MediumArray▶ animated

    Pick the most non-overlapping activities by sorting on END time and always grabbing the next one that fits.

Sorting

  1. 18

    Bubble Sort

    EasyArray▶ animated

    Sort by repeatedly swapping adjacent out-of-order pairs until settled.

  2. 19

    Insertion Sort

    EasyArray▶ animated

    Grow a sorted prefix by inserting each next element into its correct spot.

  3. 20

    Merge Sort

    MediumArray▶ animated

    Divide the array in half, sort each half, then merge them. O(n log n).

  4. 21

    Quicksort

    MediumArray▶ animated

    Pick a pivot, push smaller values left and bigger ones right, then repeat on each side. O(n log n) on average.

Recursion & dynamic programming

  1. 22

    Recursion: Factorial

    EasyRecursion▶ animated

    See recursion as a call stack: calls push on the way down, pop on the way up.

  2. 23

    Backtracking

    HardTree▶ animated

    Explore choices as a decision tree — make a choice, recurse, then UNDO it and try the next one.

  3. 24

    DP: Climbing Stairs

    EasyGrid / DP▶ animated

    Count ways to climb n stairs (1 or 2 at a time) by filling a DP table.

  4. 25

    DP: Unique Paths (Grid)

    EasyGrid / DP▶ animated

    Count right/down paths across a grid — the clearest 2D DP, where the table IS the map.

  5. 26

    DP: Coin Change

    MediumGrid / DP▶ animated

    Fewest coins to make an amount by building up a best-answer table, one amount at a time.

  6. 27

    DP: Longest Increasing Subsequence

    MediumGrid / DP▶ animated

    Find the longest run of increasing numbers (not necessarily next to each other) with a dp[] table.

  7. 28

    DP: 0/1 Knapsack

    MediumGrid / DP▶ animated

    Pack a weight-limited bag for maximum value by filling a 2D best-value table.

  8. 29

    DP: Edit Distance

    HardGrid / DP▶ animated

    Fewest insert/delete/replace edits to turn one word into another — the classic 2D string DP.

Trees

  1. 30

    Tree Traversal (In-order)

    MediumTree▶ animated

    In-order traversal of a BST (left → node → right) visits values in sorted order.

  2. 31

    Trie (Prefix Tree)

    MediumTree▶ animated

    A tree of letters where words that start the same share the same path — the magic behind autocomplete.

  3. 32

    Binary Search Tree

    MediumTree▶ animated

    Keep left < node < right at every node, and searching becomes one walk straight down — binary search on a tree.

  4. 33

    B-Tree Insert (how an index grows)

    MediumTree▶ animated

    A BST can grow into a lopsided line. A B-tree stays short by SPLITTING: when a node overfills, its middle key jumps up. Watch it stay balanced.

  5. 34

    Segment Tree: Range Sum

    HardTree▶ animated

    Store the sum of every range in a tree so a range-sum query reads a few nodes (O(log n)) instead of adding every element.

  6. 35

    Heap (Priority Queue)

    MediumTree▶ animated

    A tree that always keeps the smallest (or largest) on top — and secretly lives in a plain array.

  7. 36

    Heapsort

    MediumTree▶ animated

    Build a max-heap, then keep pulling the biggest off the top and parking it at the end. Guaranteed O(n log n), in place.

  8. 37

    Union-Find (Disjoint Sets)

    MediumTree▶ animated

    A tiny structure that answers 'are these two things connected?' almost instantly — the heart of network and MST algorithms.

Graphs

  1. 38

    How Graphs Are Stored

    EasyGraph▶ animated

    A graph is dots and lines — but a computer stores it as numbers. See the picture, the matrix, and the list as the same graph.

  2. 39

    Breadth-First Search

    MediumGraph▶ animated

    Explore a graph level by level using a queue — nearest nodes first.

  3. 40

    Depth-First Search

    MediumGraph▶ animated

    Explore a graph by going deep down one path before backtracking.

  4. 41

    Topological Sort

    MediumGraph▶ animated

    Order tasks so every prerequisite comes before the task that needs it — using DFS on a directed graph.

  5. 42

    Dijkstra's Shortest Path

    HardGraph▶ animated

    Find the cheapest route through a weighted graph by always finalizing the closest node next.

  6. 43

    Bellman-Ford Shortest Path

    HardGraph▶ animated

    Find shortest paths even with NEGATIVE roads by relaxing every edge V-1 times.

  7. 44

    All-Pairs Shortest Paths (Floyd-Warshall)

    HardGrid / DP▶ animated

    Find the cheapest cost between EVERY pair of towns by filling a distance matrix with a triple loop.

  8. 45

    Minimum Spanning Tree (Kruskal)

    MediumGraph▶ animated

    Connect every town with the cheapest total road and no loops by adding edges cheapest-first.

  9. 46

    Routing (shortest path)

    MediumGraph▶ animated

    How the internet picks a route: the fastest path, not the fewest hops. Watch routers find the lowest-latency way across a mesh.