请输入您要查询的百科知识:

 

词条 Longest increasing subsequence
释义

  1. Example

  2. Relations to other algorithmic problems

  3. Efficient algorithms

  4. Length bounds

  5. Online algorithms

  6. See also

  7. References

  8. External links

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, including algorithmics, random matrix theory, representation theory, and physics.[1] The longest increasing subsequence problem is solvable in time O(n log n), where n denotes the length of the input sequence.[2]

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 unique: for instance,

0, 4, 6, 9, 11, 15 or

0, 2, 6, 9, 13, 15 or

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 S is the longest common subsequence of S and T, where T is the result of sorting S. However, for the special case in which the input is a permutation of the integers 1, 2, ..., n, this approach can be made much more efficient, leading to time bounds of the form O(n log log n).[2]

The largest clique in a permutation graph is defined by the longest decreasing subsequence of the permutation that defines the graph; the longest decreasing subsequence is equivalent in computational complexity, by negation of all numbers, to the longest increasing subsequence. Therefore, longest increasing subsequence algorithms can be used to solve the clique problem efficiently in permutation graphs.[3]

In the Robinson–Schensted correspondence between permutations 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.[4]

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 X[0], X[1], etc. Then, after processing X[i], the algorithm will have stored values in two arrays:

M[j] — stores the index k of the smallest value X[k] such that there is an increasing subsequence of length j ending at X[k] on the range ki. Note that j(i+1), because j ≥ 1 represents the length of the increasing subsequence, and k ≥ 0 represents the index of its termination.

P[k] — stores the index of the predecessor of X[k] in the longest increasing subsequence ending at X[k].

In addition the algorithm stores a variable L representing the length of the longest increasing subsequence found so far. Because the algorithm below uses zero-based numbering, for clarity M is padded with M[0], which goes unused so that M[j] corresponds to a subsequence of length j. A real implementation can skip M[0] and adjust the indices accordingly.

Note that, at any point in the algorithm, the sequence

X[M[1]], X[M[2]], ..., X[M[L]]

is increasing. For, if there is an increasing subsequence of length j ≥ 2 ending at X[M[j]], then there is also a subsequence of length j-1 ending at a smaller value: namely the one ending at X[P[M[j]]]. Thus, we may do binary searches in this sequence in logarithmic time.

The algorithm, then, proceeds as follows:

   P = array of length N  M = array of length N + 1   L = 0  '''for''' i '''in range''' 0 '''to''' N-1:    // Binary search for the largest positive j ≤ L    // such that X[M[j]] <= X[i]    lo = 1    hi = L    '''while''' lo ≤ hi:      mid = ceil((lo+hi)/2)      '''if''' X[M[mid]] <= X[i]:        lo = mid+1      '''else''':        hi = mid-1     // After searching, lo is 1 greater than the    // length of the longest prefix of X[i]    newL = lo     // The predecessor of X[i] is the last index of     // the subsequence of length newL-1    P[i] = M[newL-1]    M[newL] = i     '''if''' newL > L:      // If we found a subsequence longer than any we've      // found yet, update L      L = newL   // Reconstruct the longest increasing subsequence  S = array of length L  k = M[L]  '''for''' i '''in range''' L-1 '''to''' 0:    S[i] = X[k]    k = P[k]   '''return''' S

Because the algorithm performs a single binary search per sequence element, its total time can be expressed using Big O notation as O(n log n). {{harvtxt|Fredman|1975}} discusses a variant of this algorithm, which he credits to Donald Knuth; in the variant that he studies, the algorithm tests whether each value X[i] can be used to extend the current longest increasing sequence, in constant time, prior to doing the binary search. With this modification, the algorithm uses at most {{nowrap|n log2 nn log2log2 n + O(n)}} comparisons in the worst case, which is optimal for a comparison-based algorithm up to the constant factor in the O(n) term.[5]

Length bounds

According to the Erdős–Szekeres theorem, any sequence of n2+1 distinct integers has an increasing or a decreasing subsequence of length {{nowrap|n + 1.[6][7]}} For inputs in which each permutation of the input is equally likely, the expected length of the longest increasing subsequence is approximately 2{{radic|n}}.

[8]

In the limit as n approaches infinity, the length of the longest increasing subsequence of a randomly permuted sequence of n items has a distribution approaching the Tracy–Widom distribution, the distribution of the largest eigenvalue of a random matrix in the Gaussian unitary ensemble.[9]

Online algorithms

The longest increasing subsequence has also been studied in the setting of online algorithms, in which the elements of a sequence of independent random variables with continuous distribution F – or alternatively the elements of a random permutation – are presented one at a time to an algorithm that must decide whether to include or exclude each element, without knowledge of the later elements. In this variant of the problem, which allows for interesting applications in several contexts, it is possible to devise an optimal selection procedure that, given a random sample of size n as input, will generate an increasing sequence with maximal expected length of size approximately {{sqrt|2n}}.

name="ss81">{{citation


| doi = 10.1214/aop/1176994265
| last1 = Samuels | first1 = Stephen. M.
| last2 = Steele | first2 = J. Michael | author2-link = J._Michael_Steele
| journal = Annals of Probability
| pages = 937–947
| title = Optimal Sequential Selection of a Monotone Sequence From a Random Sample
| volume = 9
| issue = 6
| year = 1981}}

The length of the increasing subsequence selected by this optimal procedure has variance approximately equal to {{sqrt|2n}}/3, and its limiting distribution is asymptotically normal after the usual centering and scaling.[10]

The same asymptotic results hold with more precise bounds for the corresponding problem in the setting of a Poisson arrival process.[11]

A further refinement in the Poisson process setting is given through the proof of a central limit theorem for the optimal selection process

which holds, with a suitable normalization, in a more complete sense than one would expect. The proof yields not only the "correct" functional limit theorem

but also the (singular) covariance matrix of the three-dimensional process summarizing all interacting processes.

[12]

See also

  • Patience sorting, an efficient technique for finding the length of the longest increasing subsequence
  • Plactic monoid, an algebraic system defined by transformations that preserve the length of the longest increasing subsequence
  • Anatoly Vershik, a Russian mathematician who studied applications of group theory to longest increasing subsequences
  • Longest common subsequence
  • Longest alternating subsequence

References

1. ^{{citation | last1 = Aldous | first1 = David | author1-link = David Aldous | last2 = Diaconis | first2 = Persi | author2-link = Persi Diaconis | doi = 10.1090/S0273-0979-99-00796-X | journal = Bulletin of the American Mathematical Society | pages = 413–432 | issue = 04 | title = Longest increasing subsequences: from patience sorting to the Baik–Deift–Johansson theorem | volume = 36 | year = 1999}}.
2. ^{{Citation |author1=Hunt, J. |author2=Szymanski, T. | title = A fast algorithm for computing longest common subsequences | journal = Communications of the ACM | year = 1977 | pages = 350–353 | doi = 10.1145/359581.359603 | issue = 5 | volume = 20 | postscript = .}}
3. ^{{citation|first=M. C.|last=Golumbic|authorlink=Martin Charles Golumbic|title=Algorithmic Graph Theory and Perfect Graphs|series=Computer Science and Applied Mathematics|publisher=Academic Press|year=1980|page=159}}.
4. ^{{Citation | doi=10.4153/CJM-1961-015-3 | authorlink=Craige Schensted | last1=Schensted | first1=C. | title=Longest increasing and decreasing subsequences | mr = 0121305 | year=1961 | journal=Canadian Journal of Mathematics | volume=13 | pages=179–191}}.
5. ^{{citation | last = Fredman | first = Michael L. | authorlink = Michael Fredman | doi = 10.1016/0012-365X(75)90103-X | issue = 1 | journal = Discrete Mathematics | pages = 29–35 | title = On computing the length of longest increasing subsequences | volume = 11 | year = 1975}}.
6. ^{{Citation | author = Erdős, Paul; Szekeres, George | title = A combinatorial problem in geometry | journal = Compositio Mathematica | volume = 2 | pages = 463–470 | year = 1935 | url = http://www.numdam.org/item?id=CM_1935__2__463_0}}.
7. ^{{citation | last = Steele | first = J. Michael | authorlink = J. Michael Steele | contribution = Variations on the monotone subsequence theme of Erdős and Szekeres | editor1-last = Aldous | editor1-first = David | editor1-link = David Aldous | editor2-last = Diaconis | editor2-first = Persi | editor2-link = Persi Diaconis | editor3-last = Spencer | editor3-first = Joel | editor3-link = Joel Spencer |display-editors = 3 | editor4-last = Steele | editor4-first = J. Michael | editor4-link = J. Michael Steele | pages = 111–131 | publisher = Springer-Verlag | series = IMA Volumes in Mathematics and its Applications | title = Discrete Probability and Algorithms | url = http://www-stat.wharton.upenn.edu/~steele/Publications/PDF/VOTMSTOEAS.pdf | volume = 72 | year = 1995}}.
8. ^{{citation | last1 = Vershik | first1 = A. M. | author1-link = A._M._Vershik | last2 = Kerov | first2 = C. V. | journal = Dokl. Akad. Nauk SSSR | pages = 1024–1027 | title = Asymptotics of the Plancheral measure of the symmetric group and a limiting form for Young tableaux | volume = 233 | year = 1977}}.
9. ^{{citation|title=On the distribution of the length of the longest increasing subsequence of random permutations|first1=Jinho|last1=Baik|first2=Percy|last2=Deift|first3=Kurt|last3=Johansson|journal=Journal of the American Mathematical Society|volume=12|year=1999|issue=4|pages=1119–1178|doi=10.1090/S0894-0347-99-00307-0|arxiv=math/9810105}}.
10. ^{{citation | doi = 10.1016/j.spa.2015.03.009 | last1 = Arlotto | first1 = Alessandro | last2 = Nguyen | first2 = Vinh V. | last3 = Steele | first3 = J. Michael | author3-link = J._Michael_Steele | journal = Stochastic Processes and their Applications | pages = 3596–3622 | title = Optimal online selection of a monotone subsequence: a central limit theorem | volume = 125 | issue = 9 | year = 2015| arxiv = 1408.6750}}
11. ^{{citation | last1 = Bruss | first1 = F. Thomas | author1-link = F._Thomas_Bruss | last2 = Delbaen | first2 = Freddy | doi = | issue = 2 | journal = Stochastic Processes and their Applications | pages = 313–342 | title = Optimal rules for the sequential selection of monotone subsequences of maximum expected length | volume = 96 | year = 2001}}.
12. ^{{citation | last1 = Bruss | first1 = F. Thomas | author1-link = F._Thomas_Bruss | last2 = Delbaen | first2 = Freddy | doi = 10.1016/j.spa.2004.09.002 | issue = 2 | journal = Stochastic Processes and their Applications | pages = 287–311 | title = A central limit theorem for the optimal selection process for monotone subsequences of maximum expected length | volume = 114 | year = 2004}}.

External links

  • Algorithmist's Longest Increasing Subsequence
  • [https://kuuatt.blogspot.com/2017/06/longest-increasing-sub-sequence-longest.html Simplified Longest Increasing Subsequence]
  • [https://stackoverflow.com/questions/22923646/number-of-all-longest-increasing-subsequences/22945390#22945390 Finding count of longest increased subsequences]
  • [https://cms.di.unipi.it/#/task/poldo/statement Poldo's diet]

4 : Problems on strings|Combinatorics|Formal languages|Dynamic programming

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/11/11 12:07:14