Goal-based paths · 12 steps
DSA for backend engineers
The structures behind caches, job queues, schedulers, rate limiters, database indexes and dependency graphs, and what each operation really costs.
- Who it is for
- Backend developers who use maps, queues and indexes daily and want to know what happens underneath and when it breaks down.
- By the end
- You can explain the cost of the collections and indexes your services rely on and choose a structure for caching, queuing, scheduling and dependency resolution.
Step 2: Dynamic arrays and buffers
Request bodies, batches and result lists are dynamic arrays; growth and copying explain memory spikes.
- ModuleM04 Built-in Collections· beginner
- 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 3: Hash maps: caches, dedup and indexes
In-memory caches, idempotency keys and deduplication are hash maps and sets; load factor and hashing explain their worst cases.
- ModuleM10 Hash Tables and Sets· intermediate
- VisualizerHash table· put/get/remove expected O(1)
- PatternHashing for constant-time lookup· O(n) expected
- ProblemHas any badge been scanned twice?· beginner · O(n) expected
- CollectionHashMap<K, V>· Java
- CollectionDictionary<TKey, TValue>· C#
Step 4: Queues and ring buffers
Job queues, bounded buffers and log tails are FIFO structures; a ring buffer gives O(1) operations with fixed memory.
- ModuleM09 Queues and Deques· beginner
- VisualizerQueue (ring buffer)· enqueue/dequeue O(1)
- CollectionQueue<T>· C#
- Collectioncollections.deque· Python
Step 5: Sorted data and binary search
Keyset pagination, range lookups and sorted indexes all depend on sorting and boundary search.
- ModuleM12 Searching· beginner
- ModuleM13 Sorting· intermediate
- LessonBinary search: halving a sorted range· M12 Searching
- LessonMerge sort: split, merge and the auxiliary buffer· M13 Sorting
- PatternBinary search on a monotonic predicate· O(log R × cost of ok)
- VisualizerMerge sort· Θ(n log n)
Step 6: Sliding windows: rate limits and metrics
Rate limiters and moving averages are sliding windows over time; the amortized argument explains why they stay cheap.
- ModuleM15 Sliding Window· intermediate
- PatternSliding window· O(n)
- ProblemThe busiest stretch of k hours· beginner · O(n)
- Complexity exerciseA while loop inside a for loop (sliding window)· Θ(n) (amortized O(1) per step)
Step 7: Trees, balanced trees and B-trees
Database indexes are B-trees and ordered maps are balanced binary trees; balance is what keeps lookups logarithmic.
- ModuleM18 Trees· intermediate
- ModuleM19 Binary Search Trees· intermediate
- ModuleM20 Balanced Trees· advanced
- VisualizerTree traversal· Θ(n)
Step 8: Priority queues: schedulers and timers
Delayed jobs, timeouts and "next event" loops pop the earliest item repeatedly, which is what a heap does in O(log n).
- ModuleM21 Heaps and Priority Queues· intermediate
- PatternTop K with a heap· O(n log k)
- CollectionPriorityQueue<E>· Java
- CollectionPriorityQueue<TElement, TPriority>· C#
Step 9: Tries: prefixes and routing
Autocomplete and longest-prefix routing tables are tries; their memory trade-off matters at scale.
- ModuleM22 Tries· intermediate
Step 10: Graphs and dependency order
Build systems, migrations and service start-up order are topological sorts; a cycle is a configuration error you can detect.
- ModuleM23 Graph Fundamentals· intermediate
- ModuleM24 BFS and DFS· intermediate
- ModuleM25 Topological Sort· intermediate
- PatternTopological ordering· O(V + E)
- PatternBreadth-first search and level order· O(V + E)
Step 11: Connectivity and grouping
Merging duplicate accounts or clustering related records is union-find over pairwise links.
- ModuleM28 Union Find· intermediate
- PatternUnion-find for connectivity· O(α(n)) amortized per operation
Step 12: Combined structures
LRU caches and randomized sets combine a hash map with a list or array, which the final module builds.