DSA — Dynamic Programming & Graphs
Practice DP and graph algorithms online with 1,500+ free MCQs — state definition, 1D and 2D DP, Knapsack, sequence DP, shortest paths, MST, topological sort, and advanced graph algorithms. Hard-interview ready.
What you'll learn
- Recognise DP problems from non-DP problems using the three trigger conditions — overlapping subproblems, optimal substructure, and a tractable state space.
- Define DP states correctly — the single highest-leverage step in solving any DP problem — and write the recurrence that connects state transitions.
- Convert between top-down memoisation and bottom-up tabulation, and apply space optimisation to drop O(n²) DP tables to O(n) where transitions allow.
- Solve 1D DP problems including linear DP, binary-decision DP (take-or-skip), and the classic problems (Fibonacci, climb stairs, house robber, coin change, maximum subarray).
- Solve 2D DP problems — grid traversal, two-sequence pairs, and the space-optimised one-row variants — that show up in interviews and contests.
- Apply the Knapsack family — 0/1, unbounded, and variants including partition equal subset sum, target sum, rod cutting, and coin change ways.
- Solve sequence DP problems — LIS, LCS, and Edit Distance — and their families, including reconstructions and constrained variants.
- Apply Interval DP (matrix chain multiplication, palindrome partitioning), Tree DP (subtree aggregations), and Bitmask DP (TSP-style state enumeration).
- Compute shortest paths with Dijkstra, Bellman-Ford, and Floyd-Warshall; find MSTs with Prim and Kruskal; perform topological sort and DAG algorithms.
- Apply Union-Find with path compression and union by rank; recognise Strongly Connected Components, bipartite checks, articulation points, and bridges.
Curriculum
- overlapping subproblems signal
- optimal substructure signal
- problem decomposability into subproblems
- polynomial state count requirement
- state space implies graph search
- implicit graph in problem statement
- weighted vs unweighted problem signal
- directed vs undirected problem signal
- dp on dag via topological order
- shortest path as dp
- memoization on graph search
- graph as state transition view of dp
About this course
Dynamic programming and graph algorithms are the topics where most interview candidates plateau. The patterns are harder, the state spaces are larger, and the recognition signals are subtler than two-pointer or sliding window. They're also the topics where FAANG interviews most often separate strong candidates from average ones. This free course gives you 1,500+ practice MCQs covering the full span of DP and graph algorithms — state definition, 1D and 2D DP, the Knapsack family, sequence DP, interval/tree/bitmask DP, shortest paths, MSTs, topological sort, Union-Find, and advanced graph algorithms — all with instant explanations on every wrong answer.
The course is Part 3 of Abekus's four-course DSA Mastery series. Take DSA: Data Structures Fundamentals and DSA — Algorithms & Core Patterns first — the patterns here build directly on recursion, BFS/DFS, and the underlying data structures. Either way, you practice one MCQ at a time, see exactly why your answer was wrong (or why the right answer worked), and move on. Twelve topics, three subtopics each, every question vetted and mapped — that's the structure.
Quick facts
- Format — 1,500+ free practice MCQs across 12 top-level topics, with instant explanations after every wrong answer.
- Duration — about 17 hours of focused practice; most learners spread it over 3–5 weeks.
- Level — advanced. Assumes solid recursion, BFS/DFS, and data-structure fluency from Parts 1 and 2.
- Cost — completely free, including the verifiable completion certificate.
- Audience — FAANG and product-company interview candidates, GATE CSE aspirants, competitive programmers chasing higher ratings, working developers preparing for senior or staff-level interviews.
- Prerequisites — finish Parts 1 and 2 of the DSA Mastery series, or have equivalent comfort with recursion, BFS/DFS, and the underlying data structures.
Who is this DP & Graphs course for?
Four audiences. First, FAANG and product-company interview candidates targeting senior roles where DP and graph questions appear in 30–50 percent of onsite rounds. Second, GATE CSE aspirants — the Algorithms section is dominated by DP recurrences and graph algorithms (shortest paths, MST, topological sort, SCC), and this course covers all of them. Third, competitive programmers stuck in the 1400–1800 Codeforces band where the breakthrough is fluency on DP state definitions and advanced graph techniques. Fourth, working developers preparing for senior or staff-level interviews where deep algorithmic problem-solving is the differentiator. The course assumes Parts 1 and 2 of the DSA Mastery series — if you're not solid on recursion and BFS/DFS, go back to Part 2 first.
What you'll learn in this DP & Graphs course
The curriculum is organised into three layers that map directly to the 12 topics. You can take them in order or jump to whichever layer matches your current gap.
DP foundations
- Introduction to DP & Graph Algorithms — the signals that tell you a problem is DP (overlapping subproblems, optimal substructure, manageable state space), the signals that tell you it's a graph problem (entities with relationships, transitions, reachability), and the boundary between them.
- DP Fundamentals — state definition (the hardest step in any DP problem), recurrence construction (writing the transition between states), and the memoisation-vs-tabulation trade-off including when each is preferred.
- 1D Dynamic Programming — linear DP patterns, binary-decision DP (take-or-not-take), and the classic 1D problems (Fibonacci, climb stairs, house robber, coin change, maximum subarray).
DP patterns
- 2D Dynamic Programming — grid DP (paths, obstacles, minimum path sum), two-index DP for pairs of sequences, and the space-optimisation patterns that drop O(n²) memory to O(n).
- Knapsack Family — 0/1 Knapsack, Unbounded Knapsack, and the canonical variants: partition equal subset sum, target sum, rod cutting, coin change ways.
- Sequence DP — the LIS family (Longest Increasing Subsequence and variants), the LCS family (Longest Common Subsequence and variants), and the Edit Distance family (Levenshtein, edit-distance variants with custom costs).
- Interval, Tree & Bitmask DP — Interval DP (matrix chain multiplication, palindrome partitioning), Tree DP (root-to-leaf and subtree-aggregate problems), and Bitmask DP for state spaces small enough to enumerate by bitmask (Travelling Salesman intro, subset-state problems).
Graph algorithms
- Shortest Paths — single-source shortest path with Dijkstra (non-negative weights), Bellman-Ford (handles negative edges, detects negative cycles), and all-pairs shortest path with Floyd-Warshall. Plus shortest-path variants — k-shortest paths, shortest path with constraints.
- Minimum Spanning Tree — MST concepts (cut property, cycle property), Prim's algorithm (priority-queue-driven), and Kruskal's algorithm (sort-and-union-find-driven).
- Topological Sort & Union-Find — topological sort for DAG ordering and dependency resolution, DAG algorithms (longest path, counting paths), and the Union-Find data structure (path compression, union by rank) that powers Kruskal's and connectivity queries.
- Advanced Graph Algorithms — Strongly Connected Components (Kosaraju, Tarjan), bipartite-graph checks and graph colouring, and articulation points and bridges for connectivity analysis.
- DP & Graph Mastery — mixed-topic questions that don't tell you the pattern up front. Concept comparisons, when-to-use-what selection, and applied scenarios. The wrap-up that simulates real interview pressure.
DP vs greedy vs brute-force — how do I know which to reach for?
The signals are well-defined once you know them. Reach for DP when the problem has overlapping subproblems (the same subcomputation appears across recursive calls) AND optimal substructure (an optimal solution can be built from optimal solutions to subproblems) AND the state space is small enough to enumerate. Reach for greedy when a local optimal choice provably leads to a global optimal (interval scheduling, fractional knapsack, MST), and verify the proof — most greedy mistakes come from trying it when the greedy property doesn't actually hold. Reach for brute force when the input size is small (n ≤ 20 for bitmask-able state, n ≤ 10 for permutation-based search). The Introduction to DP & Graph Algorithms topic in this course names the trigger conditions precisely.
What's the best way to learn dynamic programming?
State definition first, recurrence second, implementation third. The single highest-leverage skill in DP is defining the right state — what does dp[i] or dp[i][j] represent? Most DP failures aren't about coding; they're about defining a state that doesn't capture enough information to write the transition. The Abekus format helps because every DP MCQ in this course shows you the state definition and the recurrence explicitly in the explanation, so you internalise the pattern of "name the state, write the transition" across hundreds of problems.
Pair the MCQ practice with implementing 3–4 DP problems end-to-end in your language of choice every week. Not 30 — three to four, done carefully, with both memoisation and tabulation forms, plus space optimisation where applicable. After 6 weeks of this rhythm alongside the MCQs, you'll have the DP vocabulary that takes most self-taught learners a year.
How MCQ-based DP and graph practice works on Abekus
You see one question at a time. It's usually a problem statement plus 4 candidate state definitions or recurrences, or a graph snippet with a complexity question. You pick the right state, the right recurrence, or the right algorithm. If you're right, you move on. If you're wrong, you get a written explanation — what the correct state was, why the alternative was wrong, what the complexity actually is. The platform tracks your accuracy per topic so you know where the gaps are. An AI guide is available alongside if you want a recurrence explained step by step.
How long this DP & Graphs course actually takes
The honest math: 1,554 MCQs at roughly 40 seconds per question works out to about 1,035 minutes — call it 17 hours. That's actual focused time. Most learners spread it across 3 to 5 weeks at 60–90 minutes per day. The DP-foundations layer (Introduction, DP Fundamentals, 1D DP) takes about 4 hours; the DP-patterns layer (2D DP, Knapsack, Sequence DP, Interval/Tree/Bitmask DP) takes 7–8 hours, with Sequence DP and Bitmask DP being the densest topics; the graph-algorithms layer (Shortest Paths, MST, Topological Sort & Union-Find, Advanced Graph, Mastery) closes in another 6 hours.
This is the slowest course in the DSA series to absorb. Plan 5–6 weeks if you're new to DP, even with Parts 1 and 2 finished. Most learners need to revisit the DP Fundamentals topic two or three times before state-definition becomes intuitive — that's normal and expected. Either timeline is fine — what matters is finishing all 12 topics.
What to take alongside or after this course
This is Part 3 of Abekus's four-course DSA Mastery series. The natural sequence is: Part 1: Data Structures Fundamentals → Part 2: Algorithms & Core Patterns → this course → DSA — Interview Mastery (Part 4, mixed mock-style problems that simulate real coding rounds).
For language pairing, take this course alongside Python Fundamentals if your Python basics need work — most modern interview prep happens in Python and Abekus's question explanations assume language familiarity. The completion certificate from this course is publicly verifiable and can be added to your resume or LinkedIn profile.
DSA Mastery
A complete Data Structures & Algorithms track on Abekus — from data-structure fundamentals through algorithmic patterns, dynamic programming and graphs, and interview-mastery mixed problems. Free MCQ practice with instant explanations, designed as a progression: each course builds on the one before
What learners say
Bitmask DP and the Advanced Graph topic (SCC, articulation points, bridges) are where this course earned its place in my prep. TSP-style state enumeration in MCQ form forced me to actually understand the recurrence. Solid contribution to my Codeforces rating climb.
Topological Sort & Union-Find is a topic most prep material undersells. Union-Find with path compression and union by rank, plus the DAG algorithms (longest path, counting paths), came up directly in two different product-company interviews I cleared.
Shortest Paths is thorough — Dijkstra, Bellman-Ford, Floyd-Warshall, and the variants. The negative-weight edge cases on Dijkstra were illuminating because most tutorials skip them. Wanted slightly more depth on Johnson's algorithm but the base coverage is comprehensive.
Sequence DP was the topic I'd been avoiding for a year. LIS family, LCS family, Edit Distance with variants — 200+ MCQs and the patterns are now second nature. The Edit Distance reconstruction questions were dense but worth every minute.
2D DP and Knapsack are taught with rare clarity. The space-optimisation MCQs — taking an O(n²) Knapsack table down to a 1D rolling array — finally clicked after this course. Cleared an Amazon onsite where 0/1 Knapsack with constraints came up as the hard problem.