GATE Computer ScienceHardGATE CS (PYQ pattern)
The length of the longest bitonic subsequence (strictly increasing and then strictly decreasing; either part may be empty-length-1) of [4, 9, 2, 10, 5, 8, 12, 3, 6, 11, 1, 7] is:
- A. 5
- B. 6
- C. 7
- D. 8
Correct answer: B. 6
Compute LIS ending at i (I[i]) and LDS starting at i (D[i]); the maximum of I[i] + D[i] − 1 is 6, for instance 4, 9, 10, 12, 11, 7 or 4, 5, 8, 12, 11, 7. The plain LIS (length 5) is not the answer, because adding a descending tail helps.
More Algorithms questions
- Four greedy rules are proposed for choosing the maximum number of mutually non-overlapping activities: I. repeatedly choose the activity…
- Which of the following statements about the 0/1 knapsack problem is/are correct? I. The O(nW) dynamic programme is polynomial in n and in…
- Six tasks have (processing time, deadline): (3,6), (2,8), (4,9), (1,5), (5,15), (2,10). They run one after another on a single machine…
- In how many ways can 12 be written as an ordered sum of parts from {1, 2, 3} such that no two adjacent parts are equal (e.g. 1+2+1+3+… is…
- Which of the following statements about dynamic programming problems is/are correct? I. The LCS of two strings can be computed in O(mn)…
- Ten houses stand in a CIRCLE with values 6, 2, 9, 4, 3, 8, 1, 7, 5, 10 (the first and last houses are neighbours). No two neighbouring…