1.

In which of the following cases the minimum no of insertions to form palindrome is maximum?(a) String of length one(b) String with all same characters(c) Palindromic string(d) Non palindromic stringThis question was addressed to me in semester exam.My query is from Minimum Insertions to form a Palindrome in chapter Dynamic Programming of Data Structures & Algorithms II

Answer»

Right answer is (d) Non palindromic STRING

The best EXPLANATION: In string of length one, string with all same characters and a palindromic string the no of INSERTIONS is ZERO since the strings are already palindromes. To convert a non-palindromic string to a palindromic string, the minimum length of string to be added is 1 which is greater than all the other above cases. Hence the minimum no of insertions to form palindrome is maximum in non-palindromic strings.



Discussion

No Comment Found

Related InterviewSolutions