Dinesh/ Blog

Article series · 12 lessons

Data structure foundations

Build a vocabulary of arrays, trees, heaps and graphs, with their costs and invariants.

Start this series

Follow the sequence below, or pick up where you left off. Nothing is locked.

What you’ll work toward & your progress

What you’ll work toward

  • Corrected the two-pointer elimination proof: nums[left] is the smallest remaining partner for nums[right]
  • MiniHashMap now validates power-of-two capacity and searches past a tombstone for an existing key before reusing it; otherwise updating a colliding key can create duplicates
  • Linked-list operations assume acyclic disjoint lists except explicit cycle tests and require valid removal positions
  • Deque front removal is approximately O(1); list append/pop at the end are amortized where resize applies
Loading this browser’s progress…

Completion is stored on this device only. Nothing is locked; start where it makes sense.

Before the first lesson

These are the starting lesson’s prerequisites, not requirements for every advanced topic below.

How to practise this subject

Draw the structure before and after an update. Check empty, singleton and repeated-value cases, and account separately for time, auxiliary storage and the returned result.

Lessons in order

  1. 01beginner · 26 min

    Arrays & Strings — Indexing, Slicing, Two-Pointer

    Apply indexing, slicing, compaction and two-pointer methods with explicit ordering, mutation, Unicode and complexity contracts.

  2. 02beginner · 25 min

    Hashmaps & Sets — Hash Functions, Collisions

    Derive hash-table lookup and collision behavior, stable hash/equality contracts, ordering limits and explicit expected versus worst-case costs.

  3. 03beginner · 25 min

    Linked Lists — Singly, Doubly, When They Win

    The data structure reviewers still love — plus the three real-world situations where a linked list actually beats an array.

  4. 04beginner · 25 min

    Stacks & Queues — LIFO/FIFO in Practice

    Apply LIFO and FIFO invariants to traversal, monotonic structures and bounded queues; distinguish local ordering from distributed guarantees.

  5. 05beginner · 25 min

    Recursion — Call Stack, Base Case, Worked Examples

    Trace recursive calls and base cases, account for memo and stack resources, and compare equivalent iterative implementations.

  6. 06beginner · 26 min

    Trees & BSTs — Traversal (BFS/DFS)

    Trace tree traversal and BST invariants with explicit height, ordering, duplicate, node-identity and range-output contracts.

  7. 07beginner · 26 min

    Heaps & Priority Queues

    Apply heap invariants to top-K, merging, medians and weighted paths while accounting for ties, storage and update costs.

  8. 08beginner · 27 min

    Graphs — Representation, BFS, DFS, Shortest Path

    Represent graphs and derive traversal, connectivity and shortest-path algorithms under explicit vertex, ordering and edge-weight contracts.

  9. 09beginner · 27 min

    Sorting — Merge, Quick, and When to Trust the Built-in

    Compare merge, quick and heap sorting with explicit stability, comparator, storage and worst-case contracts, including when to use Python built-ins.

  10. 10beginner · 27 min

    Binary Search — the Pattern Behind 100 Problems

    Derive exact search, insertion boundaries and binary search on a monotone answer predicate, with shrinking-interval proofs, shipping-capacity witnesses and explicit cost assumptions.

  11. 11beginner · 28 min

    Dynamic Programming — Memoisation & Tabulation

    Define states, transitions, base cases and evaluation order; derive time and storage from the actual state space rather than assuming polynomial complexity.

  12. 12beginner · 27 min

    Greedy & Backtracking — When to Use Each

    Prove greedy choices for the precise objective, and build complete backtracking searches with correct undo, sound pruning and explicit output costs.