Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write a python code for this? The class sample code on finding an LCS of two strings returns the leftmost LCS with respect to X.

  1. write a python code for this?
  2. The class sample code on finding an LCS of two strings returns the leftmost LCS with respect to X. Modify the class code to return the leftmost LCS with respect to Y and the rightmost LCS with respect to X.
  3. Let X = AABCCDIEEDSCYBA and Y = ABBCDDEFDHCNBAT. Return the leftmost LCS with respect to Y, and the rightmost LCS with respect to X.

Definition: Let L be an LCS of X and Y. Let L[0] denote the first symbol in L (assuming index starts from 0). Denote by X(L[0]) the index of L[0] in X and by Y[L[0]) the index of L[0] in Y.

  • L is said to be the leftmost LCS with respect to X if for any other LCS H: X(H[0]) >= X(L[0]) and the index of each other symobl in L is as close as possible to the index of its proceeding symbol in X.
  • L is said to be the leftmost LCS with respect to Y if for any other LCS H: Y(H[0]) >= Y(L[0]) and the index of each other symbol in L is as close as possible to the index of its proceeding symbol in Y.

For example, Let X = "abcd' and Y = 'badc'. There are 4 LCS's: 'ac', 'ad', 'bd', and 'bc'. Here 'ac' is the leftmost LCS with respect to X and 'bd' is the leftmost LCS with respect to Y.

The rightmost LCS with respect to X (or Y) is symmtrical. Let L[k-1] denote the last symbol in L with k = len(L). Denote by X(L[k-1]) the index of L[k-1] in X and by Y(L[k-1]) the index of L[k-1] in Y.

  • L is said to be the rightmost LCS with respect to X if for any other LCS H: X(H[k-1])
  • L is said to be the rightmost LCS with respect to Y if for any other LCS H: Y(H[k-1])

In the above example, 'bd' is the rightmost LCS with respect to X, and 'ac' is the rightmost LCS with respect to Y.

Note: Let L be a leftmost (rightmost) LCS for X and Y, then LR is the rightmost (leftmost) LCS for XR and YR, where XR is the reversal of X. Your code should avoid directly using this trick. That is, your code should have a separatre function for each case without simply reversing the input for a previous function.

image text in transcribed
in the above exmyle, of is te mathoe Les with resced is x and ac' is the righ thoat LCs with reseect by

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_2

Step: 3

blur-text-image_3

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

Practical Oracle8I Building Efficient Databases

Authors: Jonathan Lewis

1st Edition

0201715848, 978-0201715842

More Books

Students also viewed these Databases questions

Question

What would help you to achieve the good life?

Answered: 1 week ago