Subsequence


In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements. For example, the sequence is a subsequence of obtained after removal of elements,, and. The relation of one sequence being the subsequence of another is a preorder.
Subsequences should not be confused with substrings such as which can be derived from the above string by deleting substring. The substring is a refinement of the subsequence.
The list of all subsequences for the word "apple" would be "a", "ap", "al", "ae", "app", "apl", "ape", "ale", "appl", "appe", "aple", "apple", "p", "pp", "pl", "pe", "ppl", "ppe", "ple", "pple", "l", "le", "e", "".

Common subsequence

Given two sequences X and Y, a sequence Z is said to be a common subsequence of X and Y, if Z is a subsequence of both X and Y. For example, if
then is said to be a common subsequence of X and Y.
This would not be the longest common subsequence, since Z only has length 3, and the common subsequence has length 4. The longest common subsequence of X and Y is.

Applications

Subsequences have applications to computer science, especially in the discipline of bioinformatics, where computers are used to compare, analyze, and store DNA, RNA, and protein sequences.
Take two sequences of DNA containing 37 elements, say:
The longest common subsequence of sequences 1 and 2 is:
This can be illustrated by highlighting the 27 elements of the longest common subsequence into the initial sequences:
Another way to show this is to align the two sequences, i.e., to position elements of the longest common subsequence in a same column and to introduce a special character in one sequence when two elements in the same column differ:
Subsequences are used to determine how similar the two strands of DNA are, using the DNA bases: adenine, guanine, cytosine and thymine.

Theorems