Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Trying to figure out part B. For part A, I defined the entry was T(i, j) that returns the length of the longest string per

image text in transcribed

Trying to figure out part B.

For part A, I defined the entry was T(i, j) that returns the length of the longest string per the above constraints of two smaller strings of X and Y going to xi and yj.

For part B, I am trying to determine what T(i, j) means and I have two cases: where the ith character in x equals the jth character of y, then I take the max of T(i - 1, j) or T(i, j - 1) or 1 + T(i - 1, j - 1).

and where the ith and jth characters are not the same, in which I take the max of T(i - 1, j) or T(i, j - 1).

Is this correct?

Given two strings X = zi,Zg, ,Fn and Y-yi,Y2, , ym, give a dynamic programming algorithm to find the length k of the longest string Z 21,... , 2k where Z appears as a substring of X and as a subsequence of Y. Recall that a substring has consecutive elements For example, consider the following input: Xa, b, d, b, a,b, f.g,d Y-b,e,t,f,d, b, f,a, f,r For this input, the answer is 4 since b, d, b, a is a substring of X and it is also a subsequence of Y For simplicity, you can assume that all table entries use O(1) space. You do not need to output the actual substring, just its length. Faster (and correct) asymptotic running time is worth more credit (a) Define the entries of your table in words. For example, T(i) or T(i,j) is... (b) State the recurrence for entries of table in terms of smaller subproblems

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

Databases A Beginners Guide

Authors: Andy Oppel

1st Edition

007160846X, 978-0071608466

More Books

Students also viewed these Databases questions

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago