Solution

ID: past-exam-of-the-year-1-of-the-computer-science-course-of-the-university-of-oxford/2017/functional-programming-design-and-analysis-of-algorithms/8/b/solution

Let be the optimal score for aligning the complete prefixes of lengths . The boundary values and recurrence are
The last candidate is omitted when the letters differ. Fill rows or columns in increasing index order and return . The final-column cases in part (a) exhaust all legal alignments and each can be appended to an optimal smaller alignment, proving the recurrence by induction on .
There are entries and at most three constant-time candidates per interior entry. Thus the time is for positive , or including empty-input boundary cases, with the same full-table space bound. Computing only the score can reduce auxiliary storage to by retaining two rows. This is global sequence alignment without mismatches; admitting a diagonal move on unequal letters would solve a different problem.

New to topics? Read the docs here!