Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(20pts) In this question, we consider the problem of finding the largest palindr

ID: 3904215 • Letter: #

Question

(20pts) In this question, we consider the problem of finding the largest palindrome subsequence. A string of characters is said to be a palindrome if the reversal is equal to itself For eg., "racecar", "civic, "a" are all palindromes. We are to construct an algorithm to solve the following problem: 2. Input: A non-empty string Output: A palindrome included in s of the maximum length The indices of a string s of length n are from 1 to n, i.e., For example, if s"civic", s1-',s12]-T, s3-,s(4]-T, and s[51-'.

Explanation / Answer

a) 6

Check symmetric positions of the string

b) 2

If not equal return false

c) 1

Else return true

d) 3

String consists of only 1 letter.

e) 11

f) 10

Check if that substring is a palindrome.

g) 10

If yes , store it.

h) 20

Assign the longer palindrome to B(i,k).

i) 13

j) 19

k) 21

For the entire string.

l) 26

Algorithm consists of 2 nested for loops . In each iteration IsPalindrome is called which further takes O(n) time.