The GATE Grind

GATE 2011 CS (CS1) – Question 35

Algorithms · Dynamic Programming · 1 mark · Multiple choice

For A[0…n−1], define Lᵢ as the longest monotonically increasing run beginning at i. Set Lₙ₋₁=1 and for earlier i, Lᵢ=1+Lᵢ₊₁ if A[i]<A[i+1], otherwise 1. Return max Lᵢ. Which is true?

  1. Uses dynamic programming
  2. Linear complexity using branch and bound
  3. Nonlinear polynomial complexity using branch and bound
  4. Uses divide and conquer

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (A) Uses dynamic programming

Explanation

The recurrence reuses the solved suffix subproblem Lᵢ₊₁ while scanning backward, a dynamic-programming strategy. It takes linear time and does not use branch and bound or divide and conquer. Thus A. The recurrence computes a contiguous increasing run, despite the source’s looser word “sequence”.

More Dynamic Programming questions

All Dynamic Programming questions →