GATE CSE 2026 Session 2 Q39: Row-wise vs anti-diagonal order for filling a DP table
- Algorithms
- 2 marks
- MCQ
- −2/3 if wrong
Question
Consider 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:
Consider the following two algorithms to compute entries of . Assume that for both the algorithms, for all , has been initialized to 1.
Algorithm B1: For i = 1, 2, ..., n
For j = 1, 2, ..., n
T[i][j] = 2T[i-1][j] + 3T[i][j-1]
Algorithm B2: For s = 2, 3, ..., 2n
For i = 1, 2, ..., n
For j = 1, 2, ..., n
If (i + j == s)
T[i][j] = 2T[i-1][j] + 3T[i][j-1]Algorithm , is said to be correct if and only if it calculates the correct values of , for all , (as per the recursive formulation) at the end of the execution of the algorithm .
Which one of the following statements is true?
Try it: multiple choice: exactly one correct option
Show answer and explanation
Answer: A (official GATE 2026 final answer key)
Concept used: A DP fill order is valid if every entry's dependencies are computed before it.
First step: depends on and ; check that both row-major order and increasing (anti-diagonal) order compute those first.
Full step-by-step solution
Detailed working, common mistakes and linked mock tests will be available with a free GATEiit account. Log-in is coming soon.
Share this question
Source: official GATE 2026 Session 2 CS question paper and final answer key, organised by IIT Guwahati. Question paper · Answer key
More Algorithms PYQs
- 2026 Session 1 · Q17Solve nested recurrences T1 = 4T1(n/2) + T2, T2 = 5T2(n/4) + log n
- 2026 Session 1 · Q41Shortest paths with at most k edges: two statements
- 2026 Session 1 · Q47Condition forcing a vertex into every minimum vertex cover
- 2026 Session 1 · Q49Cycle and cut properties of MSTs with distinct weights
- 2026 Session 1 · Q50Impossible DFS discovery/finish orderings for a DAG edge
- 2026 Session 1 · Q55Properties of 2-colorable (bipartite) graphs