What’s inside.
Each chapter has a complete program to run, the time and memory cost, and exercises.
- 00
Install a C++ compiler and prepare your workspace
Set up GCC, Clang or Visual Studio, compile with warnings on, and run your first program.
- 01
C++ foundations for DSA
Enough C++ for your first algorithms: types, functions, loops, vectors and unsigned sizes.
- 02
Vectors, arrays, maps and sets
The everyday containers, what each operation costs, and what operator[] does to a map.
- 03
Strings, bytes and characters
Why std::string holds bytes, and how to handle text without splitting a character.
- 04
Structs, references and pointers
Value semantics, references, pointers and default comparisons for your own types.
- 05
Recursion
Base cases, smaller problems, and the fixed stack that every call uses.
- 06
- 07
- 08
Hash tables and unordered_map
How a key finds its bucket, a small chained table, and the cost of a lookup.
See hash tables visualized - 09
Trees and binary search trees
Insert, search and traverse a BST, and compare it with std::set.
See trees visualized - 10
Heaps and priority queues
Write a min-heap, then use std::priority_queue with the right comparator.
See heaps visualized - 11
Searching and sorting
lower_bound without off-by-one errors, merge sort, and comparators that are strict.
- 12
Two pointers, sliding windows and prefix sums
Three ways to stop rescanning elements, with half-open ranges and sums that do not overflow.
- 13
Divide and conquer and backtracking
Count inversions by splitting, and search choices while undoing each one.
- 14
- 15
Greedy algorithms
When the locally best choice is optimal, and a counterexample when it is not.
- 16
Dynamic programming
State, recurrence and base cases, with sentinels that cannot overflow.
- 17
Mixed practice and a small C++ project
Choose a technique without a chapter title to help, and build a study planner.
Prefer another language? Go for DSA, JavaScript for DSA, Python for DSA or Java for DSA.