LongestIncreasingSubsequence
The length of a longest increasing subsequence.
✓ checked against that system · ! checked, with disagreements (hover a chip)Wikipedia
Longest increasing subsequenceWikidataQ4183855FindStatSt000062via Permutation✓Rosetta CodeLongest increasing subsequenceLongestIncreasingSubsequence(p)The length of a longest increasing subsequence.Combinatorica
Length[LongestIncreasingSubsequence[p]]SageMathenumeratio_stat("Permutation", p, "LongestIncreasingSubsequence")Typed signatures
| Type | Package | Applies |
|---|---|---|
(list<integer> | permutation) -> number | combinatorics | always |
Details
- Defined over
Permutationas an expression in_x, evaluated by compute-engine — the definition IS the implementation. - Takes a
Permutation, and also a bare list of integers: this reading compares entries with each other rather than with their positions, so it stands on any sequence. - By patience sorting: the number of piles. Checked against the piles algorithm over every permutation of 1..6.
Definition
Epsil, as the implementation runs it.
on Permutation, over _x
0 if Length(_x) < 1 else Count(Fold(Function(Apply(
Function(
Join(a, [b]) if k >
Count(a) else ReplaceAt(a, k, b),
k,
),
Count(Filter(
a,
Function(
t <
b,
t,
),
)) + 1,
), a, b), [], _x))Examples
Basic #
Properties #
About
| Examples | 6 |
|---|---|
| Checked against | Combinatorica 3 agreeSageMath 6 agree |
| Crosswalk | WikipediaWikidataFindStatCombinatoricaSageMathRosetta Code |
Implementation
mapped
combinatoricapackages/oracle/src/mappings.tsCombinatorica returns a longest subsequence; ours is its length.
mapped
sagepackages/oracle/src/mappings.ts