Lably
Skip to content

Subsequence

Mathematical binary relation

  • 2 min read
  • 3 chapters

Related on Lably

Through Mathematics, Sequence and Computer science

Subsequences can contain consecutive elements which were not consecutive in the original sequence. A subsequence which consists of a consecutive run of elements from the original sequence, such as ⟨B,C,D⟩, from ⟨A,B,C,D,E,F⟩, is a 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", "" (empty string).

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 X=⟨A,C,B,D,E,G,C,E,D,B,G⟩ and Y=⟨B,E,G,J,C,F,E,K,B⟩ and Z=⟨B,E,E⟩. then Z 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 ⟨B,E,E,B⟩ has length 4. The longest common subsequence of X and Y is ⟨B,E,G,C,E,B⟩.

Sign in to keep reading

2 more chapters are free with a Lably account.

More in Topics in mathematics