Skip to content
Codescope

Track 05 · Data Structures

The Data Structures track

Arrays, lists, trees, heaps and graphs — watch the pointers move and the search space shrink.

69 concepts mapped · 15 interactive now · 110 steps · free, no login

IntermediateBuild on the fundamentals with the mechanics working developers meet daily.

01Complexity

1 of 3 live

The vocabulary for saying why one solution beats another.

  1. 01

    Big-O notation

    Counting how work grows with n, and ignoring everything else.

    intro8 min6 steps
    0%
  2. 02

    Amortised analysis

    upcoming

    Why an occasionally expensive operation can still be O(1) on average.

  3. 03

    Space complexity

    upcoming

    Extra memory as a cost, including the stack recursion uses.

02Arrays & strings

3 of 5 live

Contiguous memory, and the techniques it makes possible.

  1. 04

    Arrays in memory

    One block, constant-time indexing, and O(n) insertion in the middle.

    intro8 min6 steps
    0%
  2. 05

    Dynamic arrays & growth

    upcoming

    Doubling capacity, and why append is amortised O(1).

  3. 06

    Two pointers

    Two indices walking one array, turning O(n²) scans into O(n).

    core10 min7 steps
    0%
  4. 07

    Sliding window

    A range that grows and shrinks instead of being rebuilt.

    core10 min8 steps
    0%
  5. 08

    Prefix sums

    upcoming

    Precompute once, answer any range query in constant time.

03Linked structures

1 of 4 live

Nodes scattered in memory, held together by references.

  1. 09

    Singly linked lists

    Every node knows only the next one. Everything the structure can and cannot do follows from that.

    core10 min8 steps
    0%
  2. 10

    Doubly linked lists

    upcoming

    A back pointer, and the deletion it makes cheap.

  3. 11

    Reversing a list

    upcoming

    Three pointers, one pass, and the order of assignments that matters.

  4. 12

    Cycle detection

    upcoming

    Floyd's slow and fast pointers, and why they must meet.

04Stacks & queues

1 of 4 live

Restricting access on purpose.

  1. 13

    Stacks

    Last in, first out — and the call stack you already met.

    intro8 min6 steps
    0%
  2. 14

    Queues & circular buffers

    upcoming

    First in, first out, with a ring so nothing has to shift.

  3. 15

    Deques

    upcoming

    Both ends open, and the operations that stay O(1).

  4. 16

    Monotonic stacks

    upcoming

    Keeping the stack sorted to answer next-greater in one pass.

05Hashing

1 of 3 live

Turning a key into an address.

  1. 17

    Hash tables

    A hash becomes a bucket index, and average O(1) lookup follows.

    core9 min6 steps
    0%
  2. 18

    Collisions

    upcoming

    Chaining and open addressing — two answers to the same problem.

  3. 19

    Sets & deduplication

    upcoming

    Membership in constant time, and the frequency-count pattern.

AdvancedDeep internals, specialist tooling, and the topics you reach for at scale.

06Trees

2 of 6 live

Hierarchies with logarithmic depth, when you keep them balanced.

  1. 20

    Binary trees

    upcoming

    Nodes, children, height — and why height decides the cost.

  2. 21

    Tree traversals

    In-order, pre-order, post-order and level-order, and what each is for.

    core11 min8 steps
    0%
  3. 22

    Binary search trees

    One ordering rule turns searching into a sequence of yes/no decisions.

    core11 min9 steps
    0%
  4. 23

    BST deletion

    upcoming

    Three cases, and the successor that replaces a two-child node.

  5. 24

    Balancing & rotations

    upcoming

    Why a sorted insert order degrades a BST into a linked list.

  6. 25

    Tries

    upcoming

    One node per character — prefix search without scanning every word.

IntermediateBuild on the fundamentals with the mechanics working developers meet daily.

07Heaps & priority queues

0 of 3 live

Fast access to the smallest thing, and nothing else.

  1. 26

    Binary heaps

    upcoming

    A tree stored in an array, with the parent always winning.

  2. 27

    Push, pop & heapify

    upcoming

    Sift up, sift down, and building a heap in O(n).

  3. 28

    Priority queues in practice

    upcoming

    Scheduling, top-k, and merging sorted streams.

08Sorting

3 of 6 live

The classic algorithms, and what separates them.

  1. 29

    Bubble, selection & insertion sort

    O(n²) sorts — and why insertion sort is still used inside fast ones.

    intro10 min6 steps
    0%
  2. 30

    Merge sort

    Divide, sort halves, merge — stable and reliably O(n log n).

    core11 min8 steps
    0%
  3. 31

    Quicksort

    Partition around a pivot, and the input that makes it O(n²).

    deep12 min8 steps
    0%
  4. 32

    Heap sort

    upcoming

    Build a heap, then pop repeatedly — in place, no extra memory.

  5. 33

    Counting & radix sort

    upcoming

    Beating O(n log n) by not comparing elements at all.

  6. 34

    Stability & choosing a sort

    upcoming

    What stability means, and when it changes your answer.

AdvancedDeep internals, specialist tooling, and the topics you reach for at scale.

09Searching

1 of 3 live

Finding things faster than looking at all of them.

  1. 35

    Binary search

    Every comparison throws away half the array. That is the whole algorithm.

    core9 min8 steps
    0%
  2. 36

    Lower & upper bound

    upcoming

    Finding the first or last match rather than any match.

  3. 37

    Binary search on the answer

    upcoming

    Searching a range of possible answers instead of an array.

10Graphs

2 of 6 live

Nodes and edges — the most general structure here.

  1. 38

    Representing a graph

    upcoming

    Adjacency list against adjacency matrix, and when each one wins.

  2. 39

    Breadth-first search

    A queue, level by level — and the shortest path in an unweighted graph.

    core11 min8 steps
    0%
  3. 40

    Depth-first search

    A stack, or recursion, and going as deep as possible first.

    core11 min8 steps
    0%
  4. 41

    Topological sort

    upcoming

    Ordering tasks so every dependency comes first.

  5. 42

    Dijkstra's algorithm

    upcoming

    Shortest paths with weights, using a priority queue.

  6. 43

    Union-find

    upcoming

    Connected components, with path compression making it near-constant.

11Recursion & dynamic programming

0 of 5 live

Solving a problem by solving smaller versions of it.

  1. 44

    Recursion & the recursion tree

    upcoming

    Drawing the calls to see the repeated work.

  2. 45

    Memoization

    upcoming

    Caching subproblems turns exponential into linear.

  3. 46

    Tabulation

    upcoming

    Filling a table bottom-up, with no recursion at all.

  4. 47

    Classic DP problems

    upcoming

    Knapsack, LCS and edit distance — the same table, different rules.

  5. 48

    Backtracking

    upcoming

    Trying a choice, undoing it, and pruning branches that cannot work.

12Balanced trees & range structures

0 of 5 live

Trees that stay short no matter the insertion order, and structures for range queries.

  1. 49

    AVL trees

    upcoming13 min

    Rebalance after every insertion with rotations to keep depth O(log n).

    • Track height at each node and detect imbalance
    • Apply LL, LR, RL, RR rotations
    • Compare AVL to red-black on rotation frequency
  2. 50

    Red-black trees

    upcoming14 min

    The tree that std::map and TreeMap actually use — coloured to keep the depth bounded.

    • State the five red-black invariants
    • Fix up colours after insertion in the six cases
    • Understand why deletion is much harder than insertion
  3. 51

    B-trees & B+ trees

    upcoming13 min

    Wide-branching trees designed for disk: one node fills a disk block.

    • Understand why databases and filesystems use B-trees, not BSTs
    • Split and merge nodes to maintain the fill invariant
    • Contrast B+ trees (leaves linked, keys duplicated) with plain B-trees
  4. 52

    Segment trees

    upcoming13 min

    Any associative range query in O(log n) — sum, min, max, gcd.

    • Build a segment tree bottom-up in O(n)
    • Point-update in O(log n)
    • Add lazy propagation for range updates
  5. 53

    Fenwick (BIT) trees

    upcoming11 min

    Prefix sums with updates — the same job as a segment tree in a fraction of the code.

    • Build a Fenwick tree from an array
    • Query prefix sums in O(log n)
    • Point-update the tree in O(log n) with the low-bit trick

13String algorithms

0 of 5 live

Doing more than a linear scan when the pattern gets clever.

  1. 54

    KMP: Knuth-Morris-Pratt

    upcoming12 min

    Never re-examine a character — precompute the failure function.

    • Compute the failure (border) array in O(m)
    • Skip forward correctly on mismatch
    • Understand why the total scan stays O(n+m)
  2. 55

    Rabin-Karp: rolling hashes

    upcoming11 min

    Hash the pattern; slide a hash across the text; compare only on hash match.

    • Choose a hash and prime that keep collisions rare
    • Update the hash in O(1) as the window slides
    • Use rolling hash for multi-pattern search
  3. 56

    Z-algorithm

    upcoming11 min

    For each position, the length of the longest prefix that matches — computed in O(n).

    • Build the Z array with the two-pointer trick
    • Solve pattern matching with a single Z pass on pattern$text
    • Compare Z, KMP, and Rabin-Karp
  4. 57

    Suffix arrays

    upcoming13 min

    Sort every suffix of a string; now any substring lives at one contiguous range.

    • Build a suffix array with SA-IS or DC3 (concept only)
    • Binary-search a pattern in O(m log n)
    • Pair with the LCP array for repeat detection
  5. 58

    Compressed & Aho-Corasick tries

    upcoming13 min

    Match many patterns in one scan of the text — the algorithm behind grep -F.

    • Compress a plain trie into a radix tree
    • Add failure links for Aho-Corasick
    • Match k patterns against text in O(n + k) total

14Advanced graphs

0 of 6 live

Beyond BFS and DFS — weighted paths, flow, and reachability tricks.

  1. 59

    Bellman-Ford & negative edges

    upcoming11 min

    Dijkstra assumes non-negative weights; Bellman-Ford does not — at O(VE) cost.

    • Relax edges V-1 times
    • Detect negative-weight cycles
    • Compare BF, Dijkstra, and SPFA
  2. 60

    Floyd-Warshall

    upcoming10 min

    All-pairs shortest paths in O(V³) — three nested loops of pure arithmetic.

    • Write the three-loop DP
    • Reconstruct paths from the parent matrix
    • Recognise when V³ is fine (small V, dense graph)
  3. 61

    Max-flow & Ford-Fulkerson

    upcoming15 min

    Push as much flow through a network as capacities allow — and prove it's the maximum.

    • Find augmenting paths in the residual graph
    • Understand the max-flow min-cut theorem
    • Compare Edmonds-Karp (BFS) with Dinic's algorithm
  4. 62

    A* search

    upcoming12 min

    Dijkstra with a heuristic — the classic pathfinder for games and maps.

    • Choose an admissible, consistent heuristic
    • Understand why Manhattan distance works for a grid and Euclidean doesn't for a road network
    • Compare A* against Dijkstra on the same map
  5. 63

    Kruskal & Prim: MST

    upcoming12 min

    Cheapest set of edges that keeps the graph connected.

    • Sort edges and add them if they don't create a cycle (Kruskal + union-find)
    • Grow a tree from a start node, always taking the cheapest crossing edge (Prim)
    • Recognise MST use cases: clustering, network design
  6. 64

    Strongly connected components

    upcoming12 min

    Group nodes that can all reach each other — via Tarjan or Kosaraju.

    • Run Kosaraju's two DFS passes
    • Follow Tarjan's low-link discovery
    • Compress a graph to its SCC DAG for further analysis

15Advanced algorithm design

0 of 5 live

The techniques you reach for when the obvious algorithm is too slow.

  1. 65

    Divide & conquer, and the master theorem

    upcoming12 min

    The recipe behind merge sort, quicksort, closest pair, and Strassen.

    • Recognise the T(n) = aT(n/b) + f(n) shape
    • Apply the three master-theorem cases
    • Use the substitution method when the master theorem doesn't apply
  2. 66

    Randomised algorithms

    upcoming12 min

    A random choice can turn worst-case O(n²) into expected O(n log n).

    • Understand why randomised quicksort dodges the sorted-input trap
    • Use reservoir sampling for a random element from a stream
    • Reason about Las Vegas vs Monte Carlo algorithms
  3. 67

    Approximation for NP-hard problems

    upcoming12 min

    Guaranteed within some ratio of optimal — because optimal is too expensive.

    • Understand 2-approximation for vertex cover
    • Greedy set cover and its ln(n) bound
    • Recognise where LP relaxation buys you an approximation
  4. 68

    Minimax & alpha-beta

    upcoming12 min

    Search a game tree to a fixed depth, and prune the branches that can't matter.

    • Implement minimax on a simple game (tic-tac-toe)
    • Add alpha-beta pruning without changing the result
    • Understand how iterative deepening plus alpha-beta enables real AI
  5. 69

    Computational geometry basics

    upcoming13 min

    Convex hulls, line-sweep, closest pair — geometry that runs in O(n log n).

    • Compute a convex hull with Graham scan or Andrew's monotone chain
    • Detect segment intersections with a sweep line
    • Find the closest pair of points in O(n log n)

The full syllabus is listed above in teaching order. Concepts marked upcoming are mapped but not yet built as visualizations. Progress is kept in this browser only.