In
computer science, the longest increasing subsequence problem is to find a subsequence of a given
sequence in which the subsequence's elements are in sorted order, lowest to highest, and in which the subsequence is as long as possible. This subsequence is not necessarily contiguous, or unique.
Longest increasing subsequences are studied in the context of various disciplines related to
mathematics
Mathematics is an area of knowledge that includes the topics of numbers, formulas and related structures, shapes and the spaces in which they are contained, and quantities and their changes. These topics are represented in modern mathematics ...
, including
algorithmics,
random matrix theory,
representation theory, and
physics. The longest increasing subsequence problem is solvable in time
where
denotes the length of the input sequence.
Example
In the first 16 terms of the binary
Van der Corput sequence
:0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15
a longest increasing subsequence is
:0, 2, 6, 9, 11, 15.
This subsequence has length six; the input sequence has no seven-member increasing subsequences. The longest increasing subsequence in this example is not the only solution: for instance,
:0, 4, 6, 9, 11, 15
:0, 2, 6, 9, 13, 15
:0, 4, 6, 9, 13, 15
are other increasing subsequences of equal length in the same input sequence.
Relations to other algorithmic problems
The longest increasing subsequence problem is closely related to the
longest common subsequence problem, which has a quadratic time
dynamic programming solution: the longest increasing subsequence of a sequence
is the longest common subsequence of
and
where
is the result of
sorting
Sorting refers to ordering data in an increasing or decreasing manner according to some linear relationship among the data items.
# ordering: arranging items in a sequence ordered by some criterion;
# categorizing: grouping items with similar pro ...
However, for the special case in which the input is a permutation of the integers
this approach can be made much more efficient, leading to time bounds of the form
The largest
clique in a
permutation graph corresponds to the longest decreasing subsequence of the permutation that defines the graph (assuming the original non-permuted sequence is sorted from lowest value to highest). Similarly, the maximum
independent set in a permutation graph corresponds to the longest non-decreasing subsequence. Therefore, longest increasing subsequence algorithms can be used to solve the
clique problem efficiently in permutation graphs.
In the
Robinson–Schensted correspondence between
permutation
In mathematics, a permutation of a set is, loosely speaking, an arrangement of its members into a sequence or linear order, or if the set is already ordered, a rearrangement of its elements. The word "permutation" also refers to the act or proc ...
s and
Young tableaux, the length of the first row of the tableau corresponding to a permutation equals the length of the longest increasing subsequence of the permutation, and the length of the first column equals the length of the longest decreasing subsequence.
[.]
Efficient algorithms
The algorithm outlined below solves the longest increasing subsequence problem efficiently with arrays and
binary searching.
It processes the sequence elements in order, maintaining the longest increasing subsequence found so far. Denote the sequence values as
etc. Then, after processing
the algorithm will have stored an integer
and values in two arrays:
*
— stores the length of the longest increasing subsequence found so far.
*