Brendan Ang

Search

Search IconIcon to open search

Alignment Problem

Last updated Nov 8, 2022 Edit Source

# Alignment Problem

# Problem Formulation

Let $n1$ and $n2$ represent the position of the character in the respective subsequence S1 and S2. The cost to align characters up till $n1$ and $n2$ can be found by finding the solutions to the cost of aligning characters $n1-1$ or $n2-1$.

If the last 2 characters are equal, the cost to align is simply the cost to align the rest of the $n1-1$ and $n2-1$ characters.

If they are not equal, we can ignore 1 character, either from n1 or n2 (resulting in $n1-1$ or $n2-1$) by replacing it with an underscore: resulting in a +1 cost. Take the minimum of this 2.

# Strategy

# Pseudocode