A contiguous subsequence of a list S is a subsequence made up of consecutive elements of S. For instance, if S is 5, 15, 30, 10, 5, 40, 10, then 15, 30, 10 is a contiguous subsequence but 5, 15, 40 is not. Give a linear-time algorithm for the following task: Input: A list of numbers, a1, a2, . . . , an. Output: The contiguous subsequence of maximum sum (a subsequence of length zero has sum zero). For the preceding example, the answer would be 10, 5, 40, 10, with a sum of 55. (Hint: For each j {1, 2, . . . , n}, consider contiguous subsequences ending exactly at position j.)
Read moreTextbook Solutions for Algorithms
Question
Exon chaining. Each gene corresponds to a subregion of the overall genome (the DNA sequence);however, part of this region might be junk DNA. Frequently, a gene consists of several piecescalled exons, which are separated by junk fragments called introns. This complicates the processof identifying genes in a newly sequenced genome.Suppose we have a new DNA sequence and we want to check whether a certain gene (a string) ispresent in it. Because we cannot hope that the gene will be a contiguous subsequence, we look forpartial matchesfragments of the DNA that are also present in the gene (actually, even thesepartial matches will be approximate, not perfect). We then attempt to assemble these fragments.Let x[1 . . . n] denote the DNA sequence. Each partial match can be represented by a triple(li, ri, wi), where x[li. . . ri] is the fragment and wi is a weight representing the strength of thematch (it might be a local alignment score or some other statistical quantity). Many of thesepotential matches could be false, so the goal is to find a subset of the triples that are consistent(nonoverlapping) and have a maximum total weight.Show how to do this efficiently
Solution
Step 1 of 3
Consider a DNA sequence as a sequence of strings. It is also called a genome. A gene is a combination of exons separated by introns. A gene is a non-contiguous subsequence in a genome. In the new genome, the beginning and the end position of the gene is located. Given are the DNA sequence and the partial matches of the gene
. The subset that has maximum weight and is non-overlapping needs to be computed.
full solution