login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A215406 A ranking algorithm for the lexicographic ordering of the Catalan families. 4

%I #31 Feb 01 2017 12:31:06

%S 0,0,1,1,1,1,1,1,1,1,2,2,3,3,3,3,1,1,1,1,2,2,2,2,3,3,3,3,3,3,3,3,2,2,

%T 2,2,2,2,3,3,3,3,4,4,5,5,5,5,5,5,6,6,7,7,7,7,8,8,8,8,8,8,8,8,2,2,2,2,

%U 2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4

%N A ranking algorithm for the lexicographic ordering of the Catalan families.

%C See Antti Karttunen's code in A057117. Karttunen writes: "Maple procedure CatalanRank is adapted from the algorithm 3.23 of the CAGES (Kreher and Stinson) book."

%C For all n>0, a(A014486(n)) = n = A080300(A014486(n)). The sequence A080300 differs from this one in that it gives 0 for those n which are not found in A014486. - _Antti Karttunen_, Aug 10 2012

%H G. C. Greubel, <a href="/A215406/b215406.txt">Table of n, a(n) for n = 0..1000</a>

%H A. Karttunen, <a href="http://www.iki.fi/~kartturi/matikka/tab9766.htm">Catalan's Triangle and ranking of Mountain Ranges</a>

%H D. L. Kreher and D. R. Stinson, <a href="http://www.math.mtu.edu/~kreher/cages.html">Combinatorial Algorithms, Generation, Enumeration and Search</a>, CRC Press, 1998.

%H F. Ruskey, <a href="http://www.cs.uvic.ca/~ruskey/Publications/Thesis/Thesis.html">Algorithmic Solution of Two Combinatorial Problems</a>, Thesis, Department of Applied Physics and Information Science, University of Victoria, 1978.

%p A215406 := proc(n) local m,a,y,t,x,u,v;

%p m := iquo(A070939(n), 2);

%p a := A030101(n);

%p y := 0; t := 1;

%p for x from 0 to 2*m-2 do

%p if irem(a, 2) = 1 then y := y + 1

%p else u := 2*m - x;

%p v := m-1 - iquo(x+y,2);

%p t := t + A037012(u,v);

%p y := y - 1 fi;

%p a := iquo(a, 2) od;

%p A014137(m) - t end:

%p seq(A215406(i),i=0..199); # _Peter Luschny_, Aug 10 2012

%t A215406[n_] := Module[{m, d, a, y, t, x, u, v}, m = Quotient[Length[d = IntegerDigits[n, 2]], 2]; a = FromDigits[Reverse[d], 2]; y = 0; t = 1; For[x = 0, x <= 2*m - 2, x++, If[Mod[a, 2] == 1, y++, u = 2*m - x; v = m - Quotient[x + y, 2] - 1; t = t - Binomial[u - 1, v - 1] + Binomial[u - 1, v]; y--]; a = Quotient[a, 2]]; (1 - I*Sqrt[3])/2 - 4^(m + 1)*Gamma[m + 3/2]*Hypergeometric2F1[1, m + 3/2, m + 3, 4]/(Sqrt[Pi]*Gamma[m + 3]) - t]; Table[A215406[n] // Simplify, {n, 0, 86}] (* _Jean-François Alcover_, Jul 25 2013, translated and adapted from Peter Luschny's Maple program *)

%o (Sage)

%o def A215406(n) : # CatalanRankGlobal(n)

%o m = A070939(n)//2

%o a = A030101(n)

%o y = 0; t = 1

%o for x in (1..2*m-1) :

%o u = 2*m - x; v = m - (x+y+1)/2

%o mn = binomial(u, v) - binomial(u, v-1)

%o t += mn*(1 - a%2)

%o y -= (-1)^a

%o a = a//2

%o return A014137(m) - t

%Y Cf. A213704, A057117, A057164, A057505, A057506, A057501, A057502, A057511, A057512, A057123, A057117, A057509, A057510, A057161, A057162, A072766, A071654, A071652, A075161, A061856, A072635, A072788, A057518, A075168, A080119, A057120, A072773.

%K nonn,look

%O 0,11

%A _Peter Luschny_, Aug 09 2012

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified September 11 23:47 EDT 2024. Contains 375842 sequences. (Running on oeis4.)