Question

1. Given two strings X and Y, a third string Z is a common superstring of X and Y if X and Y are both subsequences of 2. (Example: if X sos and Y soft, then Z sosft is a common superstring of X and Y.) Design a dynamic programming algorithm which, given as input two strings X and Y, returns the length of the shortest common superstring (SCS) of X and Y. Specifically, you have to write a recurrence of Xi and Yu, and the pseudocode. The algorithm, which has to return (n, m), must run in time 6(n Tra where n IXI and m YI. (Hint: use an approach similar to the one used to compute the length of a LCS of two strings.)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1) Find Longest Common Subsequence (lcs) of two given strings. For example, lcs of 'sos' and 'soft', 'so'

2) Insert non-lcs characters (in their original order in strings) to the lcs found above, and return the result. So “so” becomes “sosft” which is shortest common superstring.

Another example

str1 = “AGGTAB” and str2 = “GXTXAYB”. LCS of str1 and str2 is “GTAB”.

we insert characters of both strings in order and we get “AGXGTXAYB”

Basically we need to find a string that has both strings as subsequences and is shortest such string. If both strings have all characters different, then result is sum of lengths of two given strings. If there are common characters, then we don’t want them multiple times as the task is to minimize length. Therefore, we fist find the longest common subsequence, take one occurrence of this subsequence and add extra characters.

Length of the shortest superstring = (Sum of lengths of given two strings) - 
                                        (Length of LCS of two given strings)
Add a comment
Know the answer?
Add Answer to:
Given two strings X and Y, a third string Z is a common superstring of X...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a pseudocode description of the printLCS () algorithm, which prints the longest common subs...

    Write a pseudocode description of the printLCS () algorithm, which prints the longest common subsequence of two strings x and y. Your algorithm should take as input the completed ïïcs Π integer array of longest common subsequence lengths, and the two strings x and y. (So, you do not have the path[] [] array - see Lecture 19, slides 100 and 101.) Your algorithm must return the specific string corresponding the length found in 1lcs [n] [m] and it should...

  • Can I please get help with this? will upvote upon completion. Problem 2. The longest common...

    Can I please get help with this? will upvote upon completion. Problem 2. The longest common substring problem is to find the longest string that is a substring of two strings. The longest common substring of the strings "ABABC", and "ABCBA" is string "ABC" of length 3. A substrings of strings is a series of consecutive letters of s. For example, "ABA” is a substring of “ABABC", but "ABAC" is not a substring of "ABABC". Design an algorithm such that...

  • Longest common subsequence (LCS) algorithms give a way to decide how similar two given strings are....

    Longest common subsequence (LCS) algorithms give a way to decide how similar two given strings are. However, sometimes, we have to filter away some common subsequences that are in some pattern. Here is a problem for you to solve. Given two strings alpha and beta, let gamma to be the longest word satisfying all of the following conditions: gamma is a subsequence of alpha. gamma is a subsequence of beta. gamma does not contain abb. Design an algorithm that finds...

  • 1. A mass of 4.00 kg is supported in the X-Y plane by two strings. String...

    1. A mass of 4.00 kg is supported in the X-Y plane by two strings. String 1 pulls up and to the left. String 2 pulls up and to the right. Both strings are attached to the ceiling. String 1 makes an angle of 40.0 degrees with the ceiling. The tension on string 1 is 35.0 N. a) Draw the free body diagram of the mass and two strings. b) What is the magnitude of the X component of the...

  • ef count_common_occurrences(word1, word2): (str, str) -> int Given two strings, word1 and word2, return how many...

    ef count_common_occurrences(word1, word2): (str, str) -> int Given two strings, word1 and word2, return how many characters in word1 are letters that also occur in word2. You can assume all characters in the given string are lowercase. Also, spaces do not count as a common character. Algorithm: - Go through each character in word1, one by one. If this character occurs in word2, then add 1 to the count. Return total count after you're done going through the characters. >...

  • Let S and T be two sequences of length n and m, respectively. When calculating the...

    Let S and T be two sequences of length n and m, respectively. When calculating the dynamic programming table to find the optimal global alignments between the two sequences S and T, we can keep pointers to find the optimal alignments by following these pointers from cell (n, m) to cell (0, 0). Each of the paths represents a different optimal alignment for the two sequences. a) Give an algorithm in O(nm) which calculates the number of different alignments between...

  • Consider the two strings "doggie dish" and "Drip coffee". What letters do they have in common?...

    Consider the two strings "doggie dish" and "Drip coffee". What letters do they have in common? That is, what is the letter intersection count for the pair of strings? Let's look at 'd' first. The first string has 2 d's (d's occurrence count is 2), while the second has just 1 d (capitalization doesn't count) - so the intersection for the strings for d is 1. What about g? There the occurrence counts are 2 and 0, so the intersection...

  •    Problem 2: Sequence similarity measure. Let 3 and y be two given DNA sequences, represented...

       Problem 2: Sequence similarity measure. Let 3 and y be two given DNA sequences, represented as strings with characters in the set {A, G, C,T}. The similarity measure of r and y is defined as the maximum score of any alignment of r and y, where the score for an alignment is computed by adding substitution score and deletion and insertion scores, as explained below. (Some operations have negative scores.) The score for changing a character T, into a...

  • 5. If we apply binary dilation to the same large object twice using the same small...

    5. If we apply binary dilation to the same large object twice using the same small structuring element, the effect, if any, of the second dilation on the object is that the object: (a) is unchanged (b) is completely removed (c) becomes larger (d) becomes smaller (e) does not change 6. Which of the following is/are true? (a) Dijkstra's algorithm can be used to find shortest paths in a network (b) Dijkstra's algorithm is a method to find straight lines...

  • 2. Given R(x,y, z, w, k, t). There are two keys: (x,y) and z. Given the...

    2. Given R(x,y, z, w, k, t). There are two keys: (x,y) and z. Given the following functional dependency: F = { {x,y}  {z,w,k,t}, z  {x,y,w,k,t }, yt}. Is R in 2nd normal form? Justify your answer. 3. Given R(x,y, z, w, k, t). There are two keys: (x,y) and z. Given the following functional dependency: F = { fd1:{x,y}  {z,w,k,t}, fd2: z  {x,y,w,k,t }, fd3:k x}. Is R in 3rd normal form? Justify your answer....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT