1.

Which of the following problems should be solved using dynamic programming?(a) Mergesort(b) Binary search(c) Longest common subsequence(d) QuicksortI had been asked this question by my college professor while I was bunking the class.My query is from Dynamic Programming in portion Dynamic Programming of Data Structures & Algorithms II

Answer»

The correct answer is (c) Longest common subsequence

For EXPLANATION: The longest common subsequence problem has both, optimal substructure and OVERLAPPING subproblems. Hence, DYNAMIC PROGRAMMING should be used the solve this problem.



Discussion

No Comment Found

Related InterviewSolutions