login
Sequence A085183 shown in base 4. Quaternary code for binary trees.
8

%I #10 Jan 12 2024 10:25:55

%S 0,1,2,11,12,21,22,30,111,112,121,122,130,211,212,221,222,230,301,302,

%T 310,320,1111,1112,1121,1122,1130,1211,1212,1221,1222,1230,1301,1302,

%U 1310,1320,2111,2112,2121,2122,2130,2211,2212,2221,2222,2230,2301,2302

%N Sequence A085183 shown in base 4. Quaternary code for binary trees.

%C This sequence gives two alternative ways to encode rooted plane binary trees (Stanley's interpretation 'c' = interpretation 'd' without the outermost edges):

%C A: scan each term from left to right and for each 0, add a leaf node to the tree (terminate a branch), for each 1, add a leftward leaning branch \, for each 2, add a rightward leaning branch / and for each 3, add a double-branch \/ and continue in left-to-right, depth-first fashion.

%C B: Like method A, but the roles of digits 1 and 2 are swapped. When one compares the generated trees to the "standard order" as specified in the illustrations for A014486, one obtains the permutation A074684/A074683 for the case A and A082356/A082355 for the case B.

%C If we assign the following weights for each digit: w(0) = -1, w(1) = w(2) = 0, w(3) = +1, then the sequence gives all base-4 numbers for which all the partial sums of digit weights (from the most significant to the least significant end) are nonnegative and the final sum is zero. The initial term 0 is considered to have no significant digits at all, so its total weight is zero also.

%H R. P. Stanley, <a href="http://www-math.mit.edu/~rstan/ec/catalan.pdf">Exercises on Catalan and Related Numbers</a>

%F a(n) = A007090(A085183(n)).

%e For the first eleven terms the following binary trees are constructed with method A. With method B we would get their mirror images, although this doesn't hold in general (e.g. for terms like 301-320).

%e ........................................................\......./......\...

%e .....................\......./.......\......./...........\......\....../...

%e ..*......\....../.....\......\......./....../.....\/......\......\.....\...

%e ..0......1......2.....11.....12.....21.....22.....30....111....112....121..

%Y Cf. A085185. Number of terms with n significant digits is given by A000108(n+1).

%K nonn,base

%O 1,3

%A _Antti Karttunen_, Jun 14 2003