OFFSET
0,2
COMMENTS
We define the n-th standard ordered rooted tree to be obtained by taking the (n-1)-th composition in standard order (graded reverse-lexicographic, A066099) as root and replacing each part with its own standard ordered rooted tree. This ranking is an ordered variation of Matula-Goebel numbers, giving a bijective correspondence between positive integers and unlabeled ordered rooted trees.
The binary encoding of an ordered tree (A014486) is obtained by replacing the internal left and right brackets with 0's and 1's, thus forming a binary number.
LINKS
EXAMPLE
The first six binary encodings are: 0, 2, 10, 12, 42, 44, and the corresponding trees have standard ranks: 1, 2, 4, 3, 8, 7.
MATHEMATICA
stcinv[q_]:=Total[2^Accumulate[Reverse[q]]]/2;
srtinv[t_]:=If[t=={}, 1, stcinv[srtinv/@t]+1];
binbalQ[n_]:=n==0||Count[IntegerDigits[n, 2], 0]==Count[IntegerDigits[n, 2], 1]&&And@@Table[Count[Take[IntegerDigits[n, 2], k], 0]<=Count[Take[IntegerDigits[n, 2], k], 1], {k, IntegerLength[n, 2]}];
bint[n_]:=If[n==0, {}, ToExpression[StringReplace[StringReplace[ToString[IntegerDigits[n, 2]/.{1->"{", 0->"}"}], ", "->""], "} {"->"}, {"]]]
Table[srtinv[bint[n]], {n, Select[Range[0, 100], binbalQ]}]
KEYWORD
nonn
AUTHOR
Gus Wiseman, Nov 21 2022
STATUS
approved