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.
Build a Dynamic Programming algorithm in Python for the following problem. Given two sequences of vowels,...
Build a Dynamic Programming algorithm in Python for the following problem. Given two sequences of vowels, find the length of longest subsequence present in both of them. NOTE: A subsequence is a sequence that appears in the same order, but not necessarily contiguous. For example, “aei”, “aeo”, “eio”, “aiu”, ... are subsequences of “aeiou”. Sample Input 1: aeiou aiu Sample Output 1: 3 Sample Input 2: aeaiueoiuaeeoeooaauoi aeuioauuuoaeieeaueuiouaiieuiuuuaoueueauaeiauuo Sample Output 2: 16 Sample Input 3: iioioieiaiauaoeoiioiiue iuuueauiaieooaoaaouaaaae Sample Output 3:...
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
Write a recursive ARM Assembly program that takes two integers as input and outputs the greatest...
Write a recursive ARM Assembly program that takes two integers as input and outputs the greatest common divisor. *I am using Eclipse DS-5 Community Workspace with A64 Instruction Set) Use the following algorithm: // Given two integers m and n: if (m < n) gcd(n, m) if n is a divisor of m gcd(m, n) = n else gcd (m, n) = gcd (n, m % n) Your program must be recursive. You must create a function that calls itself,...
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.
What is the relation between the two outputs of 74ls151?Is ENABLE input active-HIGH or active-LOW? a)...
What is the relation between the two outputs of 74ls151?Is ENABLE input active-HIGH or active-LOW? a) Identify the ENABLE pins for 74ls138 chip. Are these pins active-HIGH or active-LOW? Are the outputs of 74ls138 active-HIGH or active-LOW? c) When used as an octal decoder, this IC converts what type of input code into a corresponding activated output? d) When used as a DEMUX, which input(s) may be used as a data line and be distributed to the output?
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.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT