An algorithm to find the length of the longest monotonically increasing…

GATE · 2011 · CS · Computer Science & IT

An algorithm to find the length of the longest monotonically increasing sequence of numbers in an array A[0:n−1]A[0:n-1] is given below.Let LiL_i, denote the length of the longest monotonically increasing sequence starting at index ii in the array.Initialize Ln−1=1L_{n-1} = 1.For all ii such that 0≤i≤n−20 \leq i \leq n-2Li={1+Li+1if A[i] < A[i+1]1OtherwiseL_i = \begin{cases} 1+ L_{i+1} & \quad\text{if A[i] < A[i+1]} \\ 1 & \quad\text{Otherwise}\end{cases}Finally, the length of the longest monotonically increasing sequence is Max(L0,L1,…,Ln−1)\text{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

Attempted by 68 students.

Sign up free to check your answer

Sign up free

Explore the full course: Algorithms

Loading lesson…