In
computer science
Computer science is the study of computation, information, and automation. Computer science spans Theoretical computer science, theoretical disciplines (such as algorithms, theory of computation, and information theory) to Applied science, ...
, a maximal pair within a string is a pair of matching substrings that are maximal, where "maximal" means that it is not possible to make a longer matching pair by extending the range of both substrings to the left or right.
Example
For example, in this table, the substrings at indices 2 to 4 (in red) and indices 6 to 8 (in blue) are a maximal pair, because they contain identical characters (
abc
), and they have different characters to the left (
x
at index 1 and
y
at index 5) and different characters to the right (
y
at index 5 and
w
at index 9). Similarly, the substrings at indices 6 to 8 (in blue) and indices 10 to 12 (in green) are a maximal pair.
However, the substrings at indices 2 to 4 (in red) and indices 10 to 12 (in green) are not a maximal pair, as the character
y
follows both substrings, and so they can be extended to the right to make a longer pair.
Formal definition
Formally, a maximal pair of substrings with starting positions
and
respectively, and both of length
, is specified by a
triple
Triple is used in several contexts to mean "threefold" or a " treble":
Sports
* Triple (baseball), a three-base hit
* A basketball three-point field goal
* A figure skating jump with three rotations
* In bowling terms, three strikes in a row
* I ...
, such that, given a string
of length
,