Skip to content

GATE CS Algorithm Design: Dynamic Programming questions

Practise Algorithm Design: Dynamic Programming questions for GATE CS. Explore official PYQs and original topic-wise quizzes, check answers and view available solutions. Free, no sign-in.

Identify the state, recurrence and base cases before choosing memoisation or tabulation. Compare related problems to recognise overlapping subproblems.

Subject, topic, year and type filter the full library. Match any choice within a filter, and all selected filter categories. Search, source and sort apply to this page.

17 on this page
Official PYQ2026AlgorithmsAlgorithm Design: Dynamic ProgrammingMCQ · 2 marks
Consider a table TT, where the elements T[i][j],0≤i,j≤nT[i][j], 0 \leq i, j \leq n, 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: …
Official PYQ2018AlgorithmsAlgorithm Design: Dynamic ProgrammingMCQ · 2 marks
Assume that multiplying a matrix G1G_1 of dimension p×qp \times q with another matrix G2G_2 of dimension q×rq \times r requires pqrpqr scalar multiplications. Computing the product of nn matrices G1G2G3…GnG_1G_2G_3 \dots G_n can be done by parenthesizing in different ways. Define GiGi+1G_i G_{i+1} as an explicitly computed pair for a given …
Official PYQ2016AlgorithmsAlgorithm Design: Dynamic ProgrammingNAT · 1 mark
Let A1,A2,A3A_{1}, A_{2}, A_{3} and A4A_{4} be four matrices of dimensions 10×5,5×20,20×1010 \times 5, 5 \times 20, 20 \times 10 and 10×510 \times 5, respectively. The minimum number of scalar multiplications required to find the product A1A2A3A4A_{1}A_{2}A_{3}A_{4} using the basic matrix multiplication method is _________.
Official PYQ2016AlgorithmsAlgorithm Design: Dynamic ProgrammingMCQ · 1 mark
The Floyd-Warshall algorithm for all-pair shortest paths computation is based on
Official PYQ2014AlgorithmsAlgorithm Design: Dynamic ProgrammingNAT · 1 mark
Consider two strings AA = "qpqrr" and BB = "pqprqrp". Let xx be the length of the longest common subsequence (not necessarily contiguous) between AA and BB and let yy be the number of such longest common subsequences between AA and BB. Then x+10y=x +10y= ___.
Official PYQ2014AlgorithmsAlgorithm Design: Dynamic ProgrammingNAT · 1 mark
Suppose you want to move from 00 to 100100 on the number line. In each step, you either move right by a unit distance or you take a shortcut. A shortcut is simply a pre-specified pair of integers i, j with i<ji,\:j \:\text{with}\: i <j. Given a shortcut (i,j)(i,j), if you are at position ii on the number line, you may directly move to jj. Suppose T(k)T(k) …
Official PYQ2011AlgorithmsAlgorithm Design: Dynamic ProgrammingMCQ · 1 mark
Consider the following recursive C function that takes two arguments. unsigned int foo(unsigned int n, unsigned int r) { if (n>0) return ((n%r) + foo(n/r, r)); else return 0; } What is the return value of the function foo\text{foo} when it is called as foo(513, 2)\text{foo(513, 2)}?
Official PYQ2011AlgorithmsAlgorithm Design: Dynamic ProgrammingMCQ · 1 mark
Consider the following recursive C function that takes two arguments. unsigned int foo(unsigned int n, unsigned int r) { if (n>0) return ((n%r) + foo(n/r, r)); else return 0; } What is the return value of the function foo\text{foo} when it is called as foo(345, 10)\text{foo(345, 10)}?
Official PYQ2011AlgorithmsAlgorithm Design: Dynamic ProgrammingMCQ · 1 mark
Four Matrices M1,M2,M3M_1, M_2, M_3 and M4M_4 of dimensions p×q,  q×r,  r×sp \times q, \:\:q \times r, \:\:r \times s and s×ts \times t respectively can be multiplied in several ways with different number of total scalar multiplications. For example when multiplied as ((M1×M2)×(M3×M4))((M_1 \times M_2) \times (M_3 \times M_4)), the total number of scalar multiplications is …
Official PYQ2011AlgorithmsAlgorithm Design: Dynamic ProgrammingMCQ · 1 mark
An algorithm to find the length of the longest monotonically increasing sequence of numbers in an array A[0:n−1]A[0:n-1] is given below. Let LiL_i, denote the length of the longest monotonically increasing sequence starting at index ii in the array. Initialize Ln−1=1L_{n-1} = 1. For all ii such that 0≤i≤n−20 \leq i \leq n-2 …
Official PYQ2010AlgorithmsAlgorithm Design: Dynamic ProgrammingMCQ · 1 mark
What is the value printed by the following C program? #include<stdio.h> int f(int *a, int n) { if (n <= 0) return 0; else if (*a % 2 == 0) return *a+f(a+1, n-1); else return *a - f(a+1, n-1); } int main() { int a[] = {12, 7, 13, 4, 11, 6}; printf("%d", f(a, 6)); return 0; }
Official PYQ2010AlgorithmsAlgorithm Design: Dynamic ProgrammingMCQ · 1 mark
The weight of a sequence a0,a1,…,an−1a_0,a_1, \dots, a_{n-1} of real numbers is defined as a0+a1/2+⋯+an−1/2n−1a_0+a_1/2+ \dots + a_{n-1}/2^{n-1}. A subsequence of a sequence is obtained by deleting some elements from the sequence, keeping the order of the remaining elements the same. Let XX denote the maximum possible weight of a subsequence of ao,a1,…,an−1a_o,a_1, \dots, a_{n-1} and …
Official PYQ2009AlgorithmsAlgorithm Design: Dynamic ProgrammingMCQ · 1 mark
A sub-sequence of a given sequence is just the given sequence with some elements (possibly none or all) left out. We are given two sequences X[m]X[m] and Y[n]Y[n] of lengths mm and nn, respectively with indexes of XX and YY starting from 00. We wish to find the length of the longest common sub-sequence (LCS) of X[m]X[m] and Y[n]Y[n] as …
Official PYQ2009AlgorithmsAlgorithm Design: Dynamic ProgrammingMCQ · 1 mark
A sub-sequence of a given sequence is just the given sequence with some elements (possibly none or all) left out. We are given two sequences X[m]X[m] and Y[n]Y[n] of lengths mm and nn, respectively with indexes of XX and YY starting from 00. We wish to find the length of the longest common sub-sequence (LCS) of X[m]X[m] and Y[n]Y[n] as …
Official PYQ2009AlgorithmsAlgorithm Design: Dynamic ProgrammingMCQ · 1 mark
Consider the program below: #include <stdio.h> int fun(int n, int *f_p) { int t, f; if (n <= 1) { *f_p = 1; return 1; } t = fun(n-1, f_p); f = t + *f_p; *f_p = t; return f; } int main() { int x = 15; printf("%d/n", fun(5, &x)); return 0; } The value printed is:
Official PYQ2008AlgorithmsAlgorithm Design: Dynamic ProgrammingMCQ · 1 mark
The subset-sum problem is defined as follows. Given a set of nn positive integers, S={a1,a2,a3,…,an}S = \{ a_1, a_2, a_3, \dots , a_n \}, and positive integer WW, is there a subset of SS whose elements sum to WW? A dynamic program for solving this problem uses a 2-dimensional\text{2-dimensional} Boolean array, XX, with nn rows and W+1W+1 columns. …
Official PYQ2008AlgorithmsAlgorithm Design: Dynamic ProgrammingMCQ · 1 mark
The subset-sum problem is defined as follows. Given a set of nn positive integers, S={a1,a2,a3,…,an}S = \{ a_1, a_2, a_3, \dots , a_n \}, and positive integer WW, is there a subset of SS whose elements sum to WW? A dynamic program for solving this problem uses a 2-dimensional\text{2-dimensional} Boolean array, XX, with nn rows and W+1W+1 columns. …