Changing the gap penalty can change which alignment is optimal.

highlighted = computed this step

A cheaper gap can change the winner

With gap penalty −1, inserting gaps beats paying for mismatches, so the traceback gives -AC aligned with CA-. With gap penalty −2, the same pair aligns as AC with CA.

gap=1: -ACCA-,gap=2: ACCA\text{gap}=−1:\ \text{-AC} \leftrightarrow \text{CA-},\quad \text{gap}=−2:\ \text{AC} \leftrightarrow \text{CA}
Gap penalty comparisonThe upper matrix uses the cheaper gap; the lower matrix uses the stronger gap.CAAC0-1-2-1-10-20-1CAAC0-2-4-2-1-1-4-1-2

The scoring scheme determines the answer

There is no single correct gap penalty. The penalty encodes a biological assumption about how costly insertions and deletions should be, and changing that assumption can change the optimal alignment.

scoring schemeoptimal alignment\text{scoring scheme} \longrightarrow \text{optimal alignment}
Gap penalty comparisonThe upper matrix uses the cheaper gap; the lower matrix uses the stronger gap.CAAC0-1-2-1-10-20-1CAAC0-2-4-2-1-1-4-1-2