Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

1583473858, 978-1583473856

More Books

Students also viewed these Databases questions