DNAs contain genetic and hereditary information of almost every living organism. DNA Sequence Matching is a procedure to compare two DNA sequences and find similarity between them. Given below is the recurrence relation of a dynamic programming algorithm to perform sequence matching of two DNAs.
seq(i,j)=max{(seq(i,j-1)-1),(seq(i-1,j)+p(i,j)),(seq(i-1,j)-1)}
where,
seq(i,j)=0, if i=0 or j=0
p(i,j)=1, if DNA1[i] = DNA2[j]
p(i,j)=-2, otherwise
As you can see, the formula takes two indices, i and j of two DNA sequences given as input. Then it produces a similarity score as output. We want to apply this formula to compare the following DNA sequences.
Now answer the following questions:
a) [CO1] Put appropriate values to fill the gaps in the line below (answer in your script):
seq(5,4) represents the final similarity score of the given DNAs.
b) [CO1] Apply the formula to calculate a similarity score between the DNA sequences given above. Show your work with either a recursion tree or a memory table.
c) [CO2] State the time complexity of this algorithm with proper reasoning. You can assume that, the lengths of the DNA sequences are N and M respectively.
d) [CO3] Mriaslun, a talented algorithmist, claims that he can implement the algorithm in an optimized way so that it only takes O(min(N,M)) space. Can you do it too? Explain your idea.