GATE 2026 set2 Computer Science and Information Technology question: Consider a table T, where the elements T[i][j], 0 i, j n, represent the cost of the…
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:
for
for
Consider the following two algorithms to compute entries of . Assume that for both the algorithms, for all , has been initialized to 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 .
Algorithm :
For i = 1, 2, …, n
For j = 1, 2, …, n
T[i][j] = 2T[i-1][j] + 3T[i][j-1]
Algorithm :
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]
Which one of the following statements is true?
Show answer
This question is in an all-India live mock that is open now. Its answer appears here when the mock closes.