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.

  1. A. I and III only
  2. B. I, II and IV only
  3. C. I, II and III only
  4. 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

Exams that ask this topic