Show the worked solutionThe efficient method keeps an array \(\text{tail}[k]\): the smallest possible last element of an increasing subsequence of length \(k\). This array stays sorted.
For each of the \(n\) numbers, binary search finds the first entry \(\ge\) it and replaces that entry (or appends).\[n\ \text{elements}\times O(\lg n)\ \text{binary search}=O(n\lg n).\]The plain dynamic program is \(O(n^2)\), so it is not the efficient one.Answer: B
GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com