Global sequence alignment without mismatches 2026-10-31
Align two complete strings using matching letters or a letter opposite a gap, with no unequal-letter columns and no double-gap columns. Give each match score one and each gap penalty . The dynamic programming table for prefixes starts with and . Its last-column cases give the displayed recurrence, where the diagonal candidate is omitted on a mismatch. Construction takes time for positive lengths and space with full alignment traceback.
An alignment with matches has gaps and score . Therefore a longest common subsequence determines its optimum. A finite mismatch penalty would solve a different problem.
Longest common subsequence Created 2026-10-20 Updated 2026-11-05
A longest common subsequence of two finite sequences has maximum length among sequences that occur in both with their original order. Characters can be skipped; this differs from requiring a contiguous substring. For and , is a common subsequence of length four.
Shortest common supersequence Created 2026-10-20 Updated 2026-11-05
A shortest common supersequence of two finite sequences is a shortest sequence containing each as a subsequence. Order is retained, but occurrences need not be contiguous. For and , is such a sequence; is another.
For lengths , its length is , where is the longest common subsequence length. Align a common subsequence of maximal length and merge the unmatched portions to prove the upper bound. Conversely, an alignment inside any common supersequence identifies at least shared positions when its length is , proving the lower bound. This formula is for two inputs; several inputs require a different analysis.