1.

What is the time complexity of the brute force algorithm used to find the length of the longest palindromic subsequence?(a) O(1)(b) O(2^n)(c) O(n)(d) O(n^2)The question was posed to me in semester exam.The origin of the question is Longest Palindromic Subsequence in division Dynamic Programming of Data Structures & Algorithms II

Answer»

Correct option is (b) O(2^n)

The BEST I can explain: In the BRUTE force ALGORITHM, all the subsequences are found and the length of the longest palindromic subsequence is calculated. This takes exponential TIME.



Discussion

No Comment Found

Related InterviewSolutions