GATE CSE Dynamic Programming PYQs
Dynamic Programming in GATE CS tests both classical tabular algorithms (such as Matrix Chain Multiplication and Rod Cutting) and structural properties of DP (su… Read the guide
- Questions
- 7
- Asked
- since 2011
- Total marks
- 11
- Marks / paper
- 0.5
7 GATE CSE Dynamic Programming PYQs with solutions, from Algorithms. Browse all GATE CSE PYQs.
Questions
Every official paper that asked this topic, newest first.
- GATE CSE 2026 Set 2 · Q39Consider a table , where the elements , represent the cost of the optimal solutions of different subproblems of a problem that is being solved using a dynamic programming algorithm. The recursive formulation to compute the table entries is as follows: …MCQ2 marksMediumSolve
- GATE CSE 2024 Set 2 · Q35Let be an array containing integer values. The distance of is defined as the minimum number of elements in that must be replaced with another integer so that the resulting array is sorted in non-decreasing order. The distance of the array is _________NAT1 markMediumSolve
- GATE CSE 2021 Set 1 · Q40Define to be the maximum amount earned by cutting a rod of length meters into one or more pieces of integer length and selling them. For , let denote the selling price of a rod whose length is meters. Consider the array of prices: …MSQ2 marksMediumSolve
- GATE CSE 2016 Set 2 · Q14The Floyd-Warshall algorithm for all-pair shortest paths computation is based onMCQ1 markEasySolve
- GATE CSE 2016 Set 2 · Q38Let , and be four matrices of dimensions , and , respectively. The minimum number of scalar multiplications required to find the product using the basic matrix multiplication method is _______.NAT2 marksMediumSolve
- GATE CSE 2014 Set 2 · Q37Consider two strings and . Let be the length of the longest common subsequence (not necessarily contiguous) between and and let be the number of such longest common subsequences between and . Then .NAT2 marksMediumSolve
- GATE CSE 2011 · Q25An algorithm to find the length of the longest monotonically increasing sequence of numbers in an array is given below. Let denote the length of the longest monotonically increasing sequence starting at index in the array. Initialize . For all such that …MCQ1 markEasySolve
What GATE tests in Dynamic Programming
Concepts, patterns, formulas and traps distilled from past papers.
Dynamic Programming in GATE CS tests both classical tabular algorithms (such as Matrix Chain Multiplication and Rod Cutting) and structural properties of DP (such as dependency graphs, evaluation orders, and state-space reductions). Questions frequently require either manual tracing of a DP table on small concrete inputs or mapping an unfamiliar problem reduction (like array replacement distance) to a standard DP formulation like Longest Non-Decreasing Subsequence. Both conceptual evaluation order questions (MCQ/MSQ) and exact numerical optimization outputs (NAT) are regularly tested.
Core concepts
- Optimal substructure and overlapping subproblems
- Dependency graph / topological ordering of DP table evaluation (row-major vs diagonal/anti-diagonal traversals)
- Matrix Chain Multiplication dynamic programming table construction
- Rod Cutting DP and enumeration of distinct optimal partition solutions
- Longest Non-Decreasing Subsequence (LNDS) and Longest Increasing Subsequence (LIS) reductions
- Contiguous vs non-contiguous subsequence DP recurrences
- Dynamic Programming Paradigm vs Greedy/Divide-and-Conquer
- Longest Common Subsequence (LCS) calculation and traceback
- Floyd-Warshall All-Pairs Shortest Path algorithm characterization
Recurring question patterns
Classical DP Table Optimization Tracing
Commonmixed2 marks2021, 2016Given a concrete instance of a standard DP problem (e.g., Matrix Chain Multiplication dimensions or Rod Cutting price arrays), manually compute the optimal cost/revenue or analyze the multiplicity of optimal solutions.
Reduction to Subsequence / Array DP
Commonmixed1 marks2024, 2011A problem is phrased as an array transformation (e.g., finding the distance to make an array sorted or finding longest increasing sequences) that reduces directly to Longest (Non-Decreasing/Monotonic) Subsequence.
DP Recurrence Dependency and Evaluation Order Analysis
OccasionalMCQ2 marks2026Given a 2D or 1D recurrence relation, analyze whether different iterative loop orderings (row-major, column-major, anti-diagonal , or backward traversal) respect the dependency graph and correctly compute all subproblems.
Design Paradigm Identification
CommonMCQ1 marks2016Direct identification of the algorithmic design technique (Greedy, Divide-and-Conquer, Dynamic Programming, etc.) underlying a classic standard algorithm.
DP Table Evaluation and Solution Enumeration
OccasionalNAT2 marks2014Tracing DP recurrences on specific short inputs (such as strings for LCS) to calculate optimal values (length) and counting the number of optimal solutions/alignments.
Formulas GATE uses
Matrix Chain Multiplication Recurrence
Computing the minimum number of scalar multiplications required to multiply a chain of matrices with dimension sequence .
Unbounded Rod Cutting Recurrence
Computing the maximum revenue attainable by cutting a rod of length with given piece prices .
Minimum Replacements to Sort Array (via LNDS)
Finding the minimum number of element replacements needed to convert an array into a non-decreasing sorted sequence.
Contiguous Monotonic Subarray DP
Computing the length of the longest contiguous monotonically increasing subarray starting at index .
Longest Common Subsequence (LCS) Recurrence
Computing the length of the longest common subsequence of two sequences and .
Floyd-Warshall All-Pairs Shortest Path Recurrence
Updating shortest paths using vertex as an intermediate node.
Examiner traps in Dynamic Programming
- Confusing contiguous subarray problems (solvable in O(n)) with non-contiguous subsequence problems (like general LIS/LNDS).
- Missing alternative optimal partitions in Rod Cutting (e.g., failing to count distinct combinations of piece lengths that yield the maximum revenue).
- Off-by-one errors in Matrix Chain Multiplication split index k or multiplying incorrect chain dimensions (pi-1pkpj).
- Assuming an alternative loop structure (such as anti-diagonal s = i+j) is incorrect without checking if all cell dependencies (i-1, j) and (i, j-1) have smaller index sums.
- Confusing the number of distinct LCS strings with the number of valid DP traceback paths/alignments.
- Off-by-one errors in indices when constructing string DP tables manually.
- Misclassifying dynamic programming graph algorithms (like Floyd-Warshall or Bellman-Ford) as greedy approaches (like Dijkstra's).
How questions are asked
- Numerical calculation of optimal cost/multiplications (NAT)
- MSQ testing both optimal DP value and structural properties/multiplicity of optimal solutions
- Code/Pseudocode verification of DP table filling orders (MCQ)
- Word-problem mapping to a classical DP recurrence (NAT/MCQ)
- Algorithm paradigm identification MCQ
- String DP computation and optimal solution count NAT
Paper trends
Shift from high-level paradigm recognition (e.g., identifying dynamic programming from a recurrence) to rigorous execution details such as verifying loop evaluation orders and topological correctness.
2026, 2011
Increased usage of NAT and MSQ formats to probe not just the optimal value, but also the number of alternative optimal solutions (multiset cuts) and reduction metrics.
2024, 2021, 2016
Questions range from direct 1-mark conceptual MCQ categorization of classical graph/DP algorithms to 2-mark computational NAT problems requiring full DP matrix execution and backtracking.
2016, 2014
Difficulty notes
Easy items test paradigm identification or straightforward 1D recurrence recognition. Medium items involve full manual evaluation of a 4-5 matrix chain, calculating unbounded knapsack/rod cutting up to with all optimal decompositions, or tracing dependency graphs across novel 2D loop orderings. Hard items typically introduce multi-constraint DP reductions or intricate state spaces.