Dynamic Programming + Divide & Conquer approach to String Alignment Problem
Nature of the Graph
Basic: Polynomial
Efficient: Linear
Explanation:
The space requirement for the basic Dynamic Programming algorithm for the sequence alignment problem is πΆ(π΄βπ΅).
The space complexity grows polynomially with the increase in the input size (The input size is M+N, where M and N are the lengths of two input strings).
This polynomial nature of the graph is due to the fact that the computation of optimal alignment between two input strings of length M and N,
respectively requires building-up a 2-dimensional M-by-N array of optimal solutions to the subproblems (Also, each of the πβπ cells of the 2-D array take constant space).The space requirement for the efficient algorithm (Divide and Conquer coupled with Dynamic Programming) is πΆ(π΄+π΅).
The space complexity grows linearly with the increase in the input size (The input size is M+N, where M and N are the lengths of two input strings).
The memory consumption is efficient due to the fact that the problem is being solved recursively thereby reusing the working space from one call to the next.
Nature of the Graph
Basic: Polynomial
Efficient: Polynomial
Explanation:
The running time or the time complexity for the basic dynamic programming algorithm for the sequence alignment problem is πΆ(π΄βπ΅).
It can be observed from the above graph that the running time grows polynomially with the increase in the input size (The input size is M+N).
This polynomial nature of the graph is due to the fact that the computation of optimal alignment between two input strings of length M and N,
respectively requires building-up a 2-dimensional M-by-N array of optimal solutions to the subproblems (Also, it takes constant time to fill each of the πβπ cells of the 2-D array).
The efficient solution (Divide and Conquer coupled with Dynamic Programming) has a time complexity of πΆ(π΄βπ΅).
It is clear from the above graph that the running time grows polynomially with the increase in the input size (The input size is M+N).
This polynomial nature can be easily identified by analysing the algorithm summing up the times at every level:
Ξ£(πΆβπβπ+πΆβπβπ2+ πΆβπβπ4+β―)=2βπβπ= π(πβπ)
