DNA2 computes all 2-element partitions of xs and ys that determine the possible deletions or insertions needed for accomplishing an alignment. This is a recursive procedure that derives alignments of two string sequences from alignments of their suffixes. DNA3 replaces the induction on suffixes by an induction on their initial positions within the original sequences xs and ys . This follows the principle of dynamic programming or memoization and provides by far the fastest solution. DNA1, DNA2 and DNA3 are cubic in the length of xs and ys .
Linear complexity is achieved by employing the accumulator technique .
Applied to DNA3, this leads to the program DNA5, which is faster than DNA3, but still considerably slower than DNA4. Abstract versions of the different solutions are presented in Sample Swinging Types , Section 2.4. The function compl maps a to t, t to a, c to g, g to c and all other strings to zzz. You'll be prompted to enter two string sequences and one of the above constraints.