Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem 7. A palindrome is a word that reads the same backwards as for- wards, for example 'racecar'. A subsequence of a word is a
Problem 7. A palindrome is a word that reads the same backwards as for- wards, for example 'racecar'. A subsequence of a word is a word that can be obtained by deleting some letters in the original word, e.g. 'mouse' is a subsequence of 'amaoulser'. Let wou represent the concatenation of two words w and u, for example house' o 'mouse' housemouse, and let E denote the empty word. The following recursive algorithm finds the longest alindrome that is a subsequence of the word w[1]w[2] n 1. MaxPal[w[1]...n]]; 2. If n = 0 return E ELSE 3. If n 1 return w[1] ELSE 4. If w[1] = w[n] return w[1]MarPal[2] w[n-1]]w[n] ELSE return Longer(MalPal[U'[2] . . . w[n]]; MazPal[u,[1] . . . w[n-1]]) Here, Longer is a routine that compares two words and returns the longer word, breaking ties arbitrarily a. List all recursive calls and their results initiated by MarPal (EDGED) b. Give a bound on the worst-case number of recursive calls MarPal could make on a word with n characters Problem 7. A palindrome is a word that reads the same backwards as for- wards, for example 'racecar'. A subsequence of a word is a word that can be obtained by deleting some letters in the original word, e.g. 'mouse' is a subsequence of 'amaoulser'. Let wou represent the concatenation of two words w and u, for example house' o 'mouse' housemouse, and let E denote the empty word. The following recursive algorithm finds the longest alindrome that is a subsequence of the word w[1]w[2] n 1. MaxPal[w[1]...n]]; 2. If n = 0 return E ELSE 3. If n 1 return w[1] ELSE 4. If w[1] = w[n] return w[1]MarPal[2] w[n-1]]w[n] ELSE return Longer(MalPal[U'[2] . . . w[n]]; MazPal[u,[1] . . . w[n-1]]) Here, Longer is a routine that compares two words and returns the longer word, breaking ties arbitrarily a. List all recursive calls and their results initiated by MarPal (EDGED) b. Give a bound on the worst-case number of recursive calls MarPal could make on a word with n characters
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started