Question 4
1/1 point
We want to determine a recursion to calculate the number of sequence alignments - c(m,n) between two sequences of size m and n, where insertions are not allowed. What is this recursion? (Note: we remind that an insertion occurs in an alignment when a non-empty character in b is mapped to an empty character in a).
c(m,n) = c(m-1,n) + c(m,n-1)
Using Dynamic Programming concept, we can solve this in a better way. The solving method is explained below:
- We will have 3 cases: Consider a 2D matrix of m*n for each case.
- Case 1: Access the c(m-1,n-1) recursion for checking an empty place at the previous diagonal position in the matrix.
- Case 2: Access the c(m-1,n) recursion for checking an empty place at the previous row of the same column position in the matrix.
- Case 3: Access the c(m,n-1) recursion for checking an empty place at the previous column of the same row position in the matrix.
Hence, the recursion will be written as c(m,n) = c(m-1,n-1) + c(m-1,n) + c(m,n-1).
Question 5
1/1 point
We use the backtracking technique to retrieve a sequence of activities that has the maximal weight. We show the dynamic array calculated by the dynamic programming algorithm seen in class in the figure below. During the backtracking procedure, we just determined that activity 4 is part of our optimal path. Which activity will be selected next in this optimal solution?
Activity predecessor Best weight V+M[p[j)] M[j-1]
a; 0
a, 0 E
a3 2 4
3 2
3 9 8
2 N
9
1) Activities sorted by finishing time. (2) Weight equal to the length of activity.
a, az ay a4 as 60 10
2
a1
a2
a3
a4
a5