GATE CS 2011 · Asymptotic Analysis & Recurrences

MCQ · 1 mark · Problem PROG-DIVC-0115

An algorithm to find the length of the longest monotonically increasing sequence of numbers in an array \(A[0:n-1]\) is given below.Let \(L_i\) denote the length of the longest monotonically increasing sequence starting at index \(i\) in the array.Initialize \(L_{n-1}=1\).For all \(i\) such that \(0\le i\le n-2\):\[L_i=\begin{cases}1+\max\{L_j : i<j<n \text{ and } A[i]<A[j]\} & \text{if such a } j \text{ exists}\\ 1 & \text{otherwise}\end{cases}\]Finally, the length of the longest monotonically increasing sequence is \(\max(L_0, L_1, \ldots, L_{n-1})\).Which of the following statements is TRUE?
  1. A
    The algorithm uses dynamic programming paradigm
  2. B
    The algorithm has a linear complexity and uses branch and bound paradigm
  3. C
    The algorithm has a non-linear polynomial complexity and uses branch and bound paradigm
  4. D
    The algorithm uses divide and conquer paradigm.

Solve it on GATE DA practice →More Searching & Sorting Algorithms problems

Show the worked solution\[\boxed{L_i \text{ is computed from the stored values } L_j,\ j>i}\]Each \(L_i\) is the answer to a subproblem, built from answers to smaller, overlapping subproblems that were computed earlier and stored (filling \(L\) from right to left). That is dynamic programming; the two nested scans take \(O(n^{2})\) time.(B), (C) Nothing is bounded or pruned, so it is not branch and bound.(D) The array is not split into independent parts, so it is not divide and conquer.Answer: A

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com