Consider a table ๐, where the elements ๐[๐][๐], 0 โค๐, ๐โค๐, 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:
๐[0][๐] = ๐[๐][0] = 1 for ๐= 0,1,2, โฆ , ๐
๐[๐][๐] = 2๐[๐โ1][๐] + 3๐[๐][๐โ1] for 1 โค๐, ๐โค๐
Consider the following two algorithms to compute entries of ๐. Assume that for
both the algorithms, for all 0 โค๐, ๐โค๐, ๐[๐][๐] 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 ๐ต๐, ๐โ{1,2} is said to be correct if and only if it calculates the correct
values of ๐[๐][๐], for all 0 โค๐, ๐โค๐, (as per the recursive formulation) at the end
of the execution of the algorithm ๐ต๐.
Which one of the following statements is true?