Longest Increasing Subsequence

Author

Eric W. Weisstein
February 3, 2006

This notebook downloaded from http://mathworld.wolfram.com/notebooks/IntegerSequences/LongestIncreasingSubsequence.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/LongestIncreasingSubsequence.html.

©2006 Wolfram Research, Inc. except for portions noted otherwise

Initialization

<< DiscreteMath`Combinatorica`

Code

LongestContinguousIncreasingSubsequence[p_]:=Last[Split[Sort[Runs[p]],Length[#1]>=Length[#2]&]]

Example

{6,3,4,8,10,5,7,1,9,2}

LongestIncreasingSubsequence[{6,3,4,8,10,5,7,1,9,2}]

LongestContinguousIncreasingSubsequence[{6,3,4,8,10,5,7,1,9,2}]

{2,5,1,4,3}

LongestIncreasingSubsequence[{2,5,1,4,3}]

LongestContinguousIncreasingSubsequence[{2,5,1,4,3}]