Question

In: Computer Science

This question concerns the case of two input sequences. Prove that every algorithm that outputs all...

This question concerns the case of two input sequences. Prove that every algorithm that outputs all
longest common subsequences of two input sequences has a worst-case running time that is exponential.
To do so, show how to define, for every positive integer n, two length-n sequences Xn, Yn
with lower bound (c^n) different longest common subsequences, where c>1 is a constant. You are allowed to use
an alphabet of size n, i.e., the symbols in Xn, Yn can come from a set {a1, a2, . . . , an}.

Solutions

Expert Solution

Prove that every algorithm that outputs all longest common subsequences of two input sequences has worst case time complexity that is exponential

The longest common subsequence (LCS) problem is the problem of finding the longest subsequence that is present in the given two sub sequences of same order.

For every positive integer n two length subsequence Xn, Yn. With lower bound (c^n). There is different longest common subsequence where c>1 is a constant.

The solution to the problem of subsequence is found by from the first subsequence deleting some items and from second subsequence deleting some items. Subsequence doesn't require to occupy consecutive position within the original subsequence.

For example consider the two subsequence of length n. Xn, Yn.

X : BDABABC

Y : ABABDC

The length of LCS is 4.

LCS are BDAB, BCAB, BCBA

The common way of soving this problem is to check every subsequence of X is also a subsequence of Y.

As there is a 2m subsequence of X the complexity of solution could be O(n.2n) .

The LCS can be solved by using

Optimal substructure

Overlapping subproblems

Optimal substructure

The problem is broken into smaller subproblems which can broken again to smaller subproblems

Let us consider the two subsequence of length n such that Xn and Yn and that both end in same element.

Then the LCS of X and Y is the longer of two subsequence LCS(X[1.. n-1], Y[n-1].

The worst case time complexity is O(2(m+n) ​​​​​​)

Overlapping subproblems

A problem is said to be a overlapping subproblems if the recursive algorithm for the problem solves the problem over and over rather than always generating new subproblems

It can be done in top down and bottom up approaches

​​​​​In top down approach a recursion tree is created for the two sequences. While forming a recursion tree we can see that the same problem is solved again and again.

Problem having optimal substructure and overlapping subproblems can be solved by dynamic programming. In which the subproblems solution are memorized rather than computing again and again.

In the bottom up approach the smaller values are calculated first then the larger values are build around them.

​​​In both these approaches the time complexity of solution is O(n2)

​​​


Related Solutions

What is the average performance of Quicksort assuming every input permutation is equally likely? Prove it....
What is the average performance of Quicksort assuming every input permutation is equally likely? Prove it. Hint: In this case pivot(split) element very likely to provide good balance during partition.
Gale-Shapley: Prove or dissprove the following theorem In every execution of the hospitals-propose Stable Matching algorithm,...
Gale-Shapley: Prove or dissprove the following theorem In every execution of the hospitals-propose Stable Matching algorithm, there is at most one hospital that makes offers to every doctor. If anyone can help me with a long-form proof or an example that dissproves this claim!
For any two real sequences {an} and {bn}, prove that Rudin’s Ex. 5 We assume that...
For any two real sequences {an} and {bn}, prove that Rudin’s Ex. 5 We assume that the right hand side is defined, that is, not of the form ∞ − ∞ or −∞ + ∞. lim sup (an + bn) ≤ lim sup an + lim sup bn. Proof If lim sup an = ∞ or lim sup bn = ∞, there is nothing to prove
For all algorithm design problems, part of the grade depends on efficiency. For every graphG =...
For all algorithm design problems, part of the grade depends on efficiency. For every graphG = (V,E), the vertex set is {1,2,··· ,n}. We use n to denote the number of vertices and m to denote number of edges. Unless otherwise stated, all graphs are represented as adjacency lists. Each problem is worth 40 points. Giveanalgorithmthat,givenanundirectedgraphGandnodes,createsanarrayShortestCountin which ShortestCount[i] is the number of shortest paths from s to vertex i. Provide a proof by induction that your algorithm is correct. Derive...
Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is:
USE Coral Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is:As long as x is greater than 0    Output x % 2 (remainder is either 0 or 1)    x = x / 2Note: The above algorithm outputs the 0's and 1's in reverse order.Ex: If the input is 6, the output is:011(6 in binary is 110; the algorithm outputs the bits in reverse).
Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is:
In Java  Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is:As long as x is greater than 0    Output x % 2 (remainder is either 0 or 1)    x = x / 2Note: The above algorithm outputs the 0's and 1's in reverse order.Ex: If the input is:6the output is:0116 in binary is 110; the algorithm outputs the bits in reverse.
It is a proof-based question. Consider a woman-proposing version of the Deferred Acceptance algorithm. Prove that...
It is a proof-based question. Consider a woman-proposing version of the Deferred Acceptance algorithm. Prove that the woman-proposing version of the Deferred Acceptance algorithm is strategy proof for women. Hint: Repeat the same steps we made in class to prove that a man-proposing DA is strategy-proof for men.
[C] Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is:
6.19 LAB: Convert to binary - functionsWrite a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is:As long as x is greater than 0    Output x % 2 (remainder is either 0 or 1)    x = x / 2Note: The above algorithm outputs the 0's and 1's in reverse order. You will need to write a second function to reverse the string.Ex: If the input is:6the output is:110Your program must define and call the following two functions. The IntegerToReverseBinary function...
(Python) Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is:
In Python8.21 Program: Convert to binary. Sections 2.7, 3.8, 5.2. Functions.Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is:As long as x is greater than 0    Output x % 2 (remainder is either 0 or 1)    x = x // 2Note: The above algorithm outputs the 0's and 1's in reverse order. You will need to write a second function to reverse the string.Your program must define and call the following two functions. The function integer_to_reverse_binary() should return...
Align two sequences shown below using Needelman Wunsch algorithm. Use match score of 3, mismatch score...
Align two sequences shown below using Needelman Wunsch algorithm. Use match score of 3, mismatch score of -3 and gap penalty score of 2 (note, you should subtract this from the scoring function). Show: a) dynamic programming matrix with scores b) trace back pointers c) alignment score sequences: sequence 1: AGAGCTCACAA sequence 2: AGTAGCTTCCAAA
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT