Data Structures & AlgorithmsVery hardGATE CS · ICPC regional
What is the length of the longest strictly increasing subsequence (not necessarily contiguous) of [3, 9, 11, 8, 12, 13, 1, 14, 5, 7, 4, 10, 2, 6]?
- A. 3
- B. 5
- C. 6
- D. 8
Correct answer: C. 6
Patience sorting maintains the smallest possible tail of each length; the answer is the number of piles. The longest decreasing subsequence, or the longest contiguous increasing run, is a different quantity.
Practise more Trees, Graphs, Recursion and Dynamic Programming questionsTrees, Graphs, Recursion and Dynamic Programming: notes and key points
More Trees, Graphs, Recursion and Dynamic Programming questions
- What is the length of the longest strictly increasing subsequence (not necessarily contiguous) of [1, 11, 4, 5, 10, 2, 8, 3, 7, 12, 13, 6…
- Elements 0 to 6 start as singletons. For each call union(a, b), in order: let ra and rb be the roots of a and b. If ra = rb nothing…
- Elements 0 to 5 start as singletons. For each call union(a, b), in order: let ra and rb be the roots of a and b. If ra = rb nothing…
- Elements 0 to 7 start as singletons. For each call union(a, b), in order: let ra and rb be the roots of a and b. If ra = rb nothing…
- A Fenwick tree t[1..6] (1-indexed, all zero at the start) is updated by add(i, v): set j = i, then while j ≤ n do { t[j] += v; j += j & −j…
- A Fenwick tree t[1..6] (1-indexed, all zero at the start) is updated by add(i, v): set j = i, then while j ≤ n do { t[j] += v; j += j & −j…