1. Home
  2. Algorithms

Filters

Found 1 Question

Set Default
Exams
Subjects
Topics

List of top Algorithms Questions on Dynamic Programming - Computation Order and Correctness of Iterative Recurrence Evaluation

Consider a table \(T\), where the elements \(T[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:

\[ T[0][k] = T[k][0] = 1 \quad \text{for } k = 0,1,2,\dots,n \] \[ T[i][j] = 2T[i-1][j] + 3T[i][j-1] \quad \text{for } 1 \leq i,j \leq n \]
Consider the following two algorithms to compute entries of \(T\). Assume that for both the algorithms, for all \(0 \leq i,j \leq n\), \(T[i][j]\) has been initialized to 1.

Algorithm \(B_1\):
For i = 1, 2, ..., n
    For j = 1, 2, ..., n
        T[i][j] = 2*T[i-1][j] + 3*T[i][j-1]

Algorithm \(B_2\):
For s = 2, 3, ..., 2n
    For i = 1, 2, ..., n
        For j = 1, 2, ..., n
            If (i + j == s)
                T[i][j] = 2*T[i-1][j] + 3*T[i][j-1]

Algorithm \(B_k\), \(k \in \{1,2\}\) is said to be correct if and only if it calculates the correct values of \(T[i][j]\), for all \(0 \leq i,j \leq n\), (as per the recursive formulation) at the end of the execution of the algorithm \(B_k\).

Which one of the following statements is true?
  • GATE CS - 2026
  • GATE CS
  • Algorithms
  • Dynamic Programming - Computation Order and Correctness of Iterative Recurrence Evaluation
contact us
terms & conditions
Privacy & Policy
© 2026 Patronum Web Private Limited