GATEverse
← GATE CSE 2011

Q25

MCQ1 mark, −0.33

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.

Loading…