A296689 Let phi be the one-to-one mapping between binary trees and natural numbers described in the Tychonievich link. Let a(n) = min({phi^{-1}(t)| size(t)=n}); i.e., a(n) is the rank -- starting from 0 -- of the first tree the size of which is n.
0, 1, 2, 4, 7, 13, 24, 30, 54, 64, 124, 244, 383, 503, 981, 1021, 1981, 3901, 6137, 8057, 13649, 16369, 32689, 65329, 98230, 130870, 229312, 261952, 491516, 524156, 1046388, 1048564, 2093044, 4182004, 8359924, 16715764, 25141220, 33497060, 58703812, 67059652, 125828996, 134184836, 259487492, 268435204, 536866564, 1073729284
Offset: 0
Keywords
Links
- Antti Karttunen, Alternative Catalan Orderings (Notes in OEIS Wiki, 2012-, see the section "Binary tree encoding with bijection")
- Luther Tychonievich, Enumerating Trees, 2013.
Programs
-
OCaml
let rec evenOdd=function(*Luther Tychonievich decomposition*) | n when n<=1 -> n,0 | n -> let ev,od=evenOdd(n/2) in 2*od+n mod 2,ev let rec cardImage=function | n when n<=1 -> n | n -> let ev,od=evenOdd(n-1) in 1+cardImage(ev)+cardImage(od) let checkCatalanBis n=(*why 2*n+1 ? empirical...*) let (first,last)=(Array.make (2*n+1) 0,Array.make (2*n+1) 0) in for i=0 to 1 lsl n do let cai=cardImage i in last.(cai)<-1+last.(cai); if first.(cai)=0 then first.(cai)<-i done; (first,last)
-
Python
def dei(n): n1 = n2 = 0 bit = 1 while n: if n&1: n1 += bit n >>= 1 if n&1: n2 += bit n >>= 1 bit <<= 1 return (n1, n2) r = [0] for n in range(1, 100): r.append(1 + sum(r[x] for x in dei(n-1))) print([r.index(x) for x in range(max(r)+1)]) # Andrey Zabolotskiy, Dec 20 2017
Comments