Question: Background: You are given two DNA sequences, sequence 1 with size n characters and sequence 2 with m characters. DNA sequences are composed of the

Background: You are given two DNA sequences, sequence1
with size n characters and sequence2 with m characters. DNA sequences are composed
of the characters A,C,G, and T. Each DNA sequence may contain two consecutive
sequences: sequence1=sequence11+sequence12 and sequence2=sequence21+sequence22.
For example, sequence1=AGACTACCG, sequence1 may contain two consecutive se-
quences sequence11= and sequence12=AGACTACCG, or sequence1 may contain two
sequences sequence11=A and sequence12=GACTACCG,... or sequence1 may contain
two sequences sequence11=AGACTACCG and sequence12=.
Your task is to find two sequences, sequence12 and sequence22, such that: (1) The
length of the longest common subsequence (LCS) of sequence12 and sequence22 is equal
to the length of the LCS of sequence1 and sequence2.(2) The total number of characters
in sequence12 and sequence22 is minimized. The output should be the length of the LCS
and the total length of the two sequences, sequence12 and sequence22, that you have
found.
An O(nm)-time algorithm is suce to pass any feasible test cases.
Hint: use the dynamic programming algorithm for longest common subsequence prob-
lem.
(a) Input You need to read the input from the console. It contains two lines, each
containing one sequence. In the first line of the input, we have n characters; and in
the second line of the input, we have m characters. You can assume that 1 n
10000 and 1 m 10000.
(b) Output You need to output to the console. The first line is an integer indicating
the length of the LCS between the given two sequences. The second line is the total
length of the two sequences, sequence12 and sequence22.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!