login
Minimum length of a longest unimodal subsequence of a permutation of n elements.
2

%I #31 Sep 08 2022 08:46:03

%S 1,2,3,3,4,4,4,5,5,5,6,6,6,6,7,7,7,7,7,8,8,8,8,8,9,9,9,9,9,9,10,10,10,

%T 10,10,10,10,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,13,13,13,13,

%U 13,13,13,13,13,14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15

%N Minimum length of a longest unimodal subsequence of a permutation of n elements.

%C a(n) is the value such that for any permutation P of n elements, P always contains a unimodal subsequence of length a(n), i.e., a sequence that is increasing, or decreasing, or increasing then decreasing.

%C n appears floor((2n+1)/3) = A004396(n) times. - _Peter Kagey_, Feb 27 2021

%H Peter Kagey, <a href="/A216256/b216256.txt">Table of n, a(n) for n = 1..10000</a>

%H F. R. K. Chung, <a href="http://dx.doi.org/10.1016/0097-3165(80)90021-7">On unimodal subsequences</a>, Journal of Combinatorial Theory, Series A, 279 (1980), pp. 267-279.

%F a(n) = ceiling(sqrt(3*n - 3/4) - 1/2).

%e a(3) = 3 because all permutations of 3 elements are unimodal.

%e a(4) = 3 because there are permutations of 4 elements (e.g., 1423) that are not unimodal, but using the previous value we can always fix that by deleting one element.

%p A216256:=n->ceil(sqrt(3*n - 3/4) - 1/2): seq(A216256(n), n=1..100); # _Wesley Ivan Hurt_, Oct 16 2015

%t Table[Ceiling[Sqrt[3 n - 3/4] - 1/2], {n, 100}] (* _Wesley Ivan Hurt_, Oct 16 2015 *)

%o (C) unsigned int a(unsigned int n) { return ceil( sqrt((double) 3*n - 0.75) - 0.5); }

%o (PARI) a(n) = ceil(sqrt(3*n-3/4) - 1/2); \\ _Michel Marcus_, Apr 22 2014

%o (Magma) [Ceiling(Sqrt(3*n - 3/4) - 1/2) : n in [1..100]]; // _Wesley Ivan Hurt_, Oct 16 2015

%Y Cf. A004396.

%K nonn,easy

%O 1,2

%A _Anthony Labarre_, Mar 15 2013