In what order should I learn data structures and algorithms?
Learn DSA in this order: Big-O, arrays, strings and searching first; then two pointers, hashing, linked lists, stacks and queues; then recursion, trees and graphs; and finally heaps, greedy algorithms, dynamic programming and backtracking. Each topic uses the ones before it, so the core takes about 16 weeks at one topic a week.
By Ronit Mexson, CTO & Co-Founder, SkillMantle · Last updated
The 16-week DSA plan, week by week
This is the plan SkillMantle's roadmap follows. Each week has one topic, one idea to understand and two problems to solve.
| Week | Topic | What you learn | Practice problems |
|---|---|---|---|
| 1 | Complexity & problem-solving basics | Big-O intuition and breaking a problem into steps | Find the maximum in an array; Count digits of a number |
| 2 | Arrays | Traversal, prefix sums and in-place updates | Reverse an array in place; Running sum of an array |
| 3 | Strings | Character manipulation and simple pattern checks | Check if a string is a palindrome; Count vowels and consonants |
| 4 | Searching | Linear search and your first binary search | Linear search; Binary search on a sorted array |
| 5 | Two pointers & sliding window | Linear-time patterns on contiguous data | Two sum on a sorted array; Longest substring without repeating characters |
| 6 | Hashing | Hash maps and sets for counting, lookup and deduplication | Group anagrams; Subarray sum equals K |
| 7 | Linked lists, stacks & queues | Pointer manipulation and LIFO/FIFO patterns | Reverse a linked list; Valid parentheses |
| 8 | Recursion & binary search | Thinking recursively and searching monotonic spaces | Generate all subsets; Search in a rotated sorted array |
| 9 | Trees & binary search trees | Traversals, recursion on trees and BST invariants | Validate a binary search tree; Lowest common ancestor |
| 10 | Graphs: BFS & DFS | Modelling problems as graphs and choosing BFS or DFS | Number of islands; Course schedule (cycle detection) |
| 11 | Heaps & greedy algorithms | Priority queues and when a greedy choice is safe | Top-K frequent elements; Merge intervals |
| 12 | Dynamic programming | Turning overlapping recursion into DP | Coin change; Longest increasing subsequence |
| 13 | Backtracking | Exploring choices systematically and pruning dead ends | N-Queens; Word search in a grid |
| 14 | Tries & union-find | Prefix trees and disjoint sets for connectivity | Implement a trie; Number of connected components |
| 15 | Advanced dynamic programming | 2D, interval and bitmask DP | Edit distance; Burst balloons |
| 16 | Mixed interview practice | Timed mixed-topic sets to practise choosing the right pattern | Timed set: arrays & hashing; Timed set: trees & graphs |
Why learn DSA in this order?
Each topic depends on the ones before it. Two pointers and sliding windows are patterns on arrays and strings. Trees are recursion on linked nodes. Graph search reuses the queue and stack from earlier weeks. Dynamic programming is recursion that remembers its answers.
Learning out of order is a common reason DSA feels hard: dynamic programming before recursion, or graphs before queues, leaves you memorising solutions instead of understanding them.
Where should you start?
| If you… | Start at | Why |
|---|---|---|
| Are new to DSA | Week 1: complexity | Big-O is how you judge every solution later. |
| Can already use arrays and strings comfortably | Week 5: two pointers | The early weeks would be revision. |
| Are comfortable with recursion and hashing | Week 9: trees | Trees and graphs are where interview problems start to need patterns. |
| Are preparing for interviews in a few weeks | Week 16: mixed practice, then fill gaps | Timed mixed sets show which topics to revisit first. |
What should you do when a problem is too hard?
Step back to the idea underneath it. If “longest substring without repeating characters” is too hard, practise a simpler sliding-window problem first, then try again. That is what SkillMantle's roadmap does automatically: when you rate a task as hard or fail its tests, it adds a short practice task on the idea underneath.
Frequently asked questions
How long does it take to learn DSA?
About 16 weeks for the core topics if you study a little every week. That is the length of this plan: one topic per week, each with a lesson and two practice problems. Allow extra time for dynamic programming and graphs, which many learners find the hardest.
Should I learn a programming language before DSA?
Yes. You should be comfortable with variables, loops, functions and lists in one language first. If you aren't yet, learn those basics, then object-oriented programming, then start this plan.
Can I skip topics I already know?
Yes. If arrays, strings and searching are easy for you, start at two pointers & sliding window (week 5). If you are comfortable up to recursion, start at trees (week 9).
How many problems should I solve per topic?
Solve at least two problems per topic, and keep going until you can solve a new one without hints. When a problem is hard, go back to the idea underneath it before moving on.