Core paths · 14 steps
Fundamentals
From precise problem statements and Big O to arrays, hashing, recursion, searching, sorting and trees: the base every later topic builds on.
- Who it is for
- New programmers, and developers who learned DSA informally and want a sound base without gaps.
- By the end
- You can state a problem precisely, estimate what a solution costs, pick a suitable built-in collection, and solve beginner problems with arrays, hashing and two pointers.
Step 1: State problems precisely
Every later step assumes you can name inputs, outputs and constraints and argue that a loop is correct; that habit is cheapest to build first.
Step 2: Count what code costs
Big O is the vocabulary for comparing every structure that follows. Counting real loops by hand makes the notation concrete.
- ModuleM03 Big O· beginner
- Complexity exerciseOne loop over the input· Θ(n)
- Complexity exerciseInner loop that depends on the outer index· Θ(n²)
- Complexity exerciseHalving until one is left· Θ(log n)
Step 3: See where data lives
Values, references and contiguous memory explain why arrays are fast and linked structures are not, before you meet either.
Step 4: Use the collections you already have
Most real code uses library collections. Knowing their costs early avoids hidden quadratic loops like repeated front insertion.
Step 5: Arrays and dynamic arrays
The array is the structure underneath most others. Seeing a dynamic array grow explains amortized O(1) append.
- ModuleM05 Arrays· beginner
- LessonDynamic arrays: capacity, resizing and amortized append· M05 Arrays
- VisualizerDynamic array· append amortized O(1); insert/remove O(n)
- Complexity exercisen appends to a doubling dynamic array· Θ(n) total, amortized O(1) per append
Step 6: Strings
Strings are arrays with encoding rules and immutability; building them efficiently is a common source of accidental O(n²).
- ModuleM06 Strings· beginner
- Complexity exerciseConcatenating immutable strings in a loop· Θ(n²) characters copied
- ProblemRun-length encode a word· beginner · O(n)
Step 7: Linked lists
Pointer-based storage is the contrast to arrays and the basis of stacks, queues and graphs.
- ModuleM07 Linked Lists· beginner
- VisualizerSingly linked list· prepend/append O(1); find/remove O(n)
Step 8: Stacks and queues
LIFO and FIFO order are the two disciplines behind parsing, undo, scheduling and graph search.
- ModuleM08 Stacks· beginner
- ModuleM09 Queues and Deques· beginner
- VisualizerStack· push/pop amortized O(1)
- VisualizerQueue (ring buffer)· enqueue/dequeue O(1)
- ProblemDo the brackets close properly?· beginner · O(n)
Step 9: Hash tables and sets
Expected O(1) lookup removes the inner loop from many brute-force solutions; it is the single most useful structure in practice.
- ModuleM10 Hash Tables and Sets· intermediate
- VisualizerHash table· put/get/remove expected O(1)
- ProblemHas any badge been scanned twice?· beginner · O(n) expected
- ProblemTwo readings that add up to a target· beginner · O(n) expected
- ProblemSame letters, different order?· beginner · O(n) expected
- PatternHashing for constant-time lookup· O(n) expected
Step 10: Recursion
Trees, divide and conquer, backtracking and dynamic programming are all recursive; the call stack must feel familiar first.
- ModuleM11 Recursion· intermediate
- Complexity exerciseRecursion that peels off one element· Θ(n)
- Complexity exerciseNaive recursive Fibonacci· Θ(φⁿ) ≈ Θ(1.618ⁿ), within O(2ⁿ)
Step 11: Linear and binary search
Binary search is the first algorithm whose cost is logarithmic, and its invariant reasoning is reused everywhere.
- ModuleM12 Searching· beginner
- LessonBinary search: halving a sorted range· M12 Searching
- VisualizerBinary search· O(log n)
Step 12: Sorting
Sorting is a building block for search, greedy algorithms and interval problems; comparing the classic sorts teaches stability and in-place trade-offs.
- ModuleM13 Sorting· intermediate
- LessonMerge sort: split, merge and the auxiliary buffer· M13 Sorting
- VisualizerInsertion sort· O(n²) worst, O(n) sorted
- VisualizerMerge sort· Θ(n log n)
- Complexity exerciseTwo halves plus linear work· Θ(n log n)
Step 13: First pattern: two pointers
With arrays, sorting and complexity in place, two pointers is the first technique that turns an O(n²) idea into O(n).
- ModuleM14 Two Pointers· intermediate
- PatternTwo pointers· O(n)
- ProblemTwo prices that fit the budget exactly· beginner · O(n)
- ProblemPush the empty slots to the end· beginner · O(n)
- ProblemDoes the phrase read the same both ways?· beginner · O(n)
Step 14: Trees and traversals
Trees close the fundamentals: they combine recursion with queues and lead into search trees, heaps and graphs.
- ModuleM18 Trees· intermediate
- VisualizerTree traversal· Θ(n)