Skip to content

Beta · Data may be lost.Your data may be reset or lost.

GateBrew
← GATE CSE 2011
Questions

Q25

MCQ1 mark, −0.33AlgorithmsEasy

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-2 Li={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, \dots , L_{n-1}). Which of the following statements is TRUE?

Sign in to save attempts.

Solutions and discussion are hidden while you attempt this question. They open once you check or show the answer.