GATE CS 2026 Set 2 | Question 39
Algorithms › Algorithm Design Techniques · MCQ · 2 marks · Answer: A
- Question 39Algorithmsmcq2 marksConsider a table , where the elements , , represent the cost of the optimal solutions of different subproblems. The recursive formulation is:All are initialized to 1. Consider the two algorithms below.
is correct iff it computes the correct for all . Which one of the following statements is true?Algorithm B1: For i = 1,2,...,n For j = 1,2,...,n T[i][j] = 2*T[i-1][j] + 3*T[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] = 2*T[i-1][j] + 3*T[i][j-1]- A.Both algorithms and are correct✓
- B.Algorithm is correct, but algorithm is incorrect
- C.Algorithm is correct, but algorithm is incorrect
- D.Both algorithms and are incorrect
Answer: A
Solution
Answer: (A) Each depends only on and (both have smaller index-sum ). - B1 (row-major): when computing , was done in the previous row and earlier in the same row. ✓ - B2 (by diagonals ): both dependencies have sum , computed in earlier diagonals. ✓ Both are correct. - A.
More GATE PYQ on Algorithm Design Techniques
All GATE CS Algorithms PYQ →Attempt GATE CS 2026 Set 2 in real GATE exam mode
Full paper with a timer, the GATE interface and a topic-wise analysis — free.
Create free account →