GATE Computer ScienceHardGATE CS (PYQ pattern)
Which of the following statements about dynamic programming problems is/are correct? I. The LCS of two strings can be computed in O(mn) time. II. The LCS of k strings, where k is part of the input, is NP-hard. III. The LIS of a sequence can be found in O(n log n) time. IV. The longest simple path in a general directed graph can be found in polynomial time by DP over vertices.
- A. I and III only
- B. I, II and IV only
- C. I, II and III only
- D. II and III only
Correct answer: C. I, II and III only
I and III are standard; II is a known NP-hardness result for an unbounded number of strings. IV is false: the longest simple path is NP-hard in general graphs (a DP over the topological order works only for DAGs).
More Algorithms questions
- 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…
- Among all full parenthesisations of the product A₁A₂A₃A₄A₅A₆A₇, how many contain the product (A₃A₄) as one of their sub-products?
- X = ABCBDAB and Y = BDCABA have longest common subsequences of length 4. How many DIFFERENT strings are shortest common supersequences of…
- The fractional knapsack greedy algorithm (taking items by value/weight ratio, the last one fractionally) is run on capacity 26 and items…
- Dijkstra's algorithm (never re-inserting or re-opening a vertex once it has been extracted) is run from S on a directed graph with edges…
- Dijkstra's algorithm with a binary min-heap (lazy insertion is not used: a decrease-key is performed whenever an edge improves the label…