Question: Just want to know what firstPalindrome function does. Write pre and post-conditions for this function. Thanks. (6 MARKS) A palindrome is a string that is

Just want to know what firstPalindrome function does. Write pre and post-conditionsJust want to know what firstPalindrome function does. Write pre and post-conditions for this function. Thanks.

(6 MARKS) A palindrome is a string that is equal to its reversal: examples are 'a', wow', and 'abcdedcba'. Consider the following algorithm. det longestPalindrome(a) : Pre: s is a non-empty string Post: returns the longest palindrome that is a substring of s. If there is more than one palindrome in s of maximnum length return >longestPalindrome ('ballaaa') alla >longestPalindrome ( 'ballaaaa') KYOU FIGURE THIS OUT> if len (s)1: return s else: palindrome1-longestPalindrome (s[1..len (s)-1]) palindrome2 firstPalindrome (s) if len (palindrome1) > len(palindrome2): return palindrome1 else: return palindrome2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!