GATE Computer ScienceHardGATE CS (PYQ pattern)
In the array [2, 5, 3, 7, 11, 8, 10, 13, 6, 9, 4, 12] the longest strictly increasing subsequences have length 6. How many different index-subsets form such a subsequence?
- A. 4
- B. 6
- C. 5
- D. 8
Correct answer: B. 6
Using L[i] and a count C[i] of increasing subsequences of that length ending at i, and summing C over all i with L[i] = 6, gives 6 (confirmed by brute-force enumeration of all subsets). Counting only the tails in the patience table gives one, not six.
More Algorithms questions
- The O(n log n) LIS algorithm keeps an array t where t[k] is the smallest tail of an increasing subsequence of length k + 1; each element x…
- The longest palindromic subsequence of the string BCABDACBDCA has length:
- What is the minimum number of cuts needed to partition the string abacbbcabbacab into substrings that are all palindromes?
- How many DIFFERENT non-empty strings occur as subsequences of BANANAB (subsequences need not be contiguous; equal strings from different…
- Ten symbols with frequencies 2, 3, 4, 5, 6, 8, 10, 15, 20, 27 (total 100) are encoded with an optimal ternary (3-ary) Huffman code, whose…
- Eight files of sizes 4, 7, 9, 12, 15, 18, 22 and 25 are merged using 3-way merges (merging any 3 files costs the sum of their sizes; merge…