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.

16-week DSA plan
WeekTopicWhat you learnPractice problems
1Complexity & problem-solving basicsBig-O intuition and breaking a problem into stepsFind the maximum in an array; Count digits of a number
2ArraysTraversal, prefix sums and in-place updatesReverse an array in place; Running sum of an array
3StringsCharacter manipulation and simple pattern checksCheck if a string is a palindrome; Count vowels and consonants
4SearchingLinear search and your first binary searchLinear search; Binary search on a sorted array
5Two pointers & sliding windowLinear-time patterns on contiguous dataTwo sum on a sorted array; Longest substring without repeating characters
6HashingHash maps and sets for counting, lookup and deduplicationGroup anagrams; Subarray sum equals K
7Linked lists, stacks & queuesPointer manipulation and LIFO/FIFO patternsReverse a linked list; Valid parentheses
8Recursion & binary searchThinking recursively and searching monotonic spacesGenerate all subsets; Search in a rotated sorted array
9Trees & binary search treesTraversals, recursion on trees and BST invariantsValidate a binary search tree; Lowest common ancestor
10Graphs: BFS & DFSModelling problems as graphs and choosing BFS or DFSNumber of islands; Course schedule (cycle detection)
11Heaps & greedy algorithmsPriority queues and when a greedy choice is safeTop-K frequent elements; Merge intervals
12Dynamic programmingTurning overlapping recursion into DPCoin change; Longest increasing subsequence
13BacktrackingExploring choices systematically and pruning dead endsN-Queens; Word search in a grid
14Tries & union-findPrefix trees and disjoint sets for connectivityImplement a trie; Number of connected components
15Advanced dynamic programming2D, interval and bitmask DPEdit distance; Burst balloons
16Mixed interview practiceTimed mixed-topic sets to practise choosing the right patternTimed 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?

Where to start in the plan
If you…Start atWhy
Are new to DSAWeek 1: complexityBig-O is how you judge every solution later.
Can already use arrays and strings comfortablyWeek 5: two pointersThe early weeks would be revision.
Are comfortable with recursion and hashingWeek 9: treesTrees and graphs are where interview problems start to need patterns.
Are preparing for interviews in a few weeksWeek 16: mixed practice, then fill gapsTimed 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.

See how the roadmap adapts or start the plan free.

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.