cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-10 of 12 results. Next

A014486 List of totally balanced sequences of 2n binary digits written in base 10. Binary expansion of each term contains n 0's and n 1's and reading from left to right (the most significant to the least significant bit), the number of 0's never exceeds the number of 1's.

Original entry on oeis.org

0, 2, 10, 12, 42, 44, 50, 52, 56, 170, 172, 178, 180, 184, 202, 204, 210, 212, 216, 226, 228, 232, 240, 682, 684, 690, 692, 696, 714, 716, 722, 724, 728, 738, 740, 744, 752, 810, 812, 818, 820, 824, 842, 844, 850, 852, 856, 866, 868, 872, 880, 906, 908, 914
Offset: 0

Views

Author

Keywords

Comments

The binary Dyck-Language (A063171) in decimal representation.
These encode width 2n mountain ranges, rooted planar trees of n+1 vertices and n edges, planar planted trees with n nodes, rooted plane binary trees with n+1 leaves (2n edges, 2n+1 vertices, n internal nodes, the root included), Dyck words, binary bracketings, parenthesizations, non-crossing handshakes and partitions and many other combinatorial structures in Catalan family, enumerated by A000108.
Is Sum_{k=1..n} a(k) / n^(5/2) bounded? - Benoit Cloitre, Aug 18 2002
This list is the intersection of A061854 and A031443. - Jason Kimberley, Jan 18 2013
The sequence does start at n = 0, since in the binary interpretation of the Dyck language (e.g., as parenthesizations where "1" stands for "(" and "0" stands for ")") having a(0) = 0 will do since it would stand for the empty string where the "0"s and "1"s are balanced (hence the parentheses are balanced). - Daniel Forgues, Feb 17 2013
It appears that for n>=1 this sequence can be obtained by concatenating the terms of the irregular array whose n-th row length is A000108(n) and that is defined recursively by B(n,0) = A020988(n) and B(n,k) = B(n, k-1) + D(n, k-1) where D(x,y) = (2^(2*(A089309(B(x,y))-1))-1)*(2/3) + 2^A007814(B(x,y)). - Raúl Mario Torres Silva and Michel Marcus, May 01 2020
This encoding is related to the ranking by standard ordered tree numbers in that (1) the binary encoding of trees ordered by standard ranking is given by A358505, while (2) the standard ranking of trees ordered by binary encoding is given by A358523. - Gus Wiseman, Nov 21 2022

Examples

			a(19) = 226_10 = 11100010_2 = A063171(19) as bracket expression: ( ( ( ) ) )( ) and as a binary tree, proceeding from left to right in depth-first fashion, with 1's in binary expansion standing for internal (branching) nodes and 0's for leaves:
  0   0
   \ /
    1   0 0  (0)
     \ /   \ /
      1     1
       \   /
         1
Note that in this coding scheme the last leaf of the binary trees (here in parentheses) is implicit. This tree can be also converted to a particular S-expression in languages like Lisp, Scheme and Prolog, if we interpret its internal nodes (1's) as cons cells with each leftward leaning branch being the "car" and the rightward leaning branch the "cdr" part of the pair, with the terminal nodes (0's) being ()'s (NILs). Thus we have (cons (cons (cons () ()) ()) (cons () ())) = '( ( ( () . () ) . () ) . ( () . () ) ) = (((())) ()) i.e., the same bracket expression as above, but surrounded by extra parentheses. This mapping is performed by the Scheme function A014486->parenthesization given below.
From _Gus Wiseman_, Nov 21 2022: (Start)
The terms and corresponding ordered rooted trees begin:
    0: o
    2: (o)
   10: (oo)
   12: ((o))
   42: (ooo)
   44: (o(o))
   50: ((o)o)
   52: ((oo))
   56: (((o)))
  170: (oooo)
  172: (oo(o))
  178: (o(o)o)
  180: (o(oo))
  184: (o((o)))
(End)
		

References

  • Donald E. Knuth, The Art of Computer Programming, Vol. 4A: Combinatorial Algorithms, Part 1, Addison-Wesley, 2011, Section 7.2.1.6, pp. 443 (Algorithm P).

Crossrefs

Characteristic function: A080116. Inverse function: A080300.
The terms of binary width 2n are counted by A000108(n). Subset of A036990. Number of peaks in each mountain (number of leaves in rooted plane general trees): A057514. Number of trailing zeros in the binary expansion: A080237. First differences: A085192.
Branches of the ordered tree are counted by A057515.
Edges of the ordered tree are counted by A072643.
The Matula-Goebel number of the ordered tree is A127301.
The standard ranking of the ordered tree is A358523.
The depth of the ordered tree is A358550.
Nodes of the ordered tree are counted by A358551.

Programs

  • Maple
    # Maple procedure CatalanUnrank is adapted from the algorithm 3.24 of the CAGES book and the Scheme function CatalanUnrank from Ruskey's thesis. See the a089408.c program for the corresponding C procedures.
    CatalanSequences := proc(upto_n) local n,a,r; a := []; for n from 0 to upto_n do for r from 0 to (binomial(2*n,n)/(n+1))-1 do a := [op(a),CatalanUnrank(n,r)]; od; od; return a; end;
    CatalanUnrank := proc(n,rr) local r,x,y,lo,m,a; r := (binomial(2*n,n)/(n+1))-(rr+1); y := 0; lo := 0; a := 0; for x from 1 to 2*n do m := Mn(n,x,y+1); if(r <= lo+m-1) then y := y+1; a := 2*a + 1; else lo := lo+m; y := y-1; a := 2*a; fi; od; return a; end;
    Mn := (n,x,y) -> binomial(2*n-x,n-((x+y)/2)) - binomial(2*n-x,n-1-((x+y)/2));
    # Alternative:
    bin := n -> ListTools:-Reverse(convert(n, base, 2)):
    isA014486 := proc(n): local B, s, b; s := 0;
        if n > 0 then
          for b in bin(n) do
              s := s + ifelse(b = 1, 1, -1);
               if 0 > s then return false fi;
          od fi;
      s = 0 end:
    select(isA014486, [seq(0..240)]);  # Peter Luschny, Mar 13 2024
  • Mathematica
    cat[ n_ ] := (2 n)!/n!/(n+1)!; b2d[li_List] := Fold[2#1+#2&, 0, li]
    d2b[n_Integer] := IntegerDigits[n, 2]
    tree[n_] := Join[Table[1, {i, 1, n}], Table[0, {i, 1, n}]]
    nexttree[t_] := Flatten[Reverse[t]/. {a___, 0, 0, 1, b___}:> Reverse[{Sort[{a, 0}]//Reverse, 1, 0, b}]]
    wood[ n_ /; n<8 ] := NestList[ nexttree, tree[ n ], cat[ n ]-1 ]
    Table[ Reverse[ b2d/@wood[ j ] ], {j, 0, 6} ]//Flatten
    (* Alternative code *)
    tbQ[n_]:=Module[{idn2=IntegerDigits[n,2]},Count[idn2,1]==Length[idn2]/2&&Min[Accumulate[idn2/.{0->-1}]]>=0]; Join[{0},Select[Range[900],tbQ]] (* Harvey P. Dale, Jul 04 2013 *)
    balancedQ[0] = True; balancedQ[n_] := Module[{s = 0}, Do[s += If[b == 1, 1, -1]; If[s < 0, Return[False]], {b, IntegerDigits[n, 2]}]; Return[s == 0] ]; A014486 = FromDigits /@ IntegerDigits[Select[Range[0, 1000], balancedQ ]] (* Jean-François Alcover, Mar 05 2016 *)
    A014486Q[0] = True; A014486Q[n_] := Catch[Fold[If[# < 0, Throw[False], If[#2 == 0, # - 1, # + 1]] &, 0, IntegerDigits[n, 2]] == 0]; Select[Range[0, 880], A014486Q] (* JungHwan Min, Dec 11 2016 *)
    (* Uses Algorithm P from Knuth's TAOCP section 7.2.1.6 - see References and Links. *)
    alist[n_] := Block[{a = Flatten[Table[{1, 0}, n]], m = 2*n - 1, j, k},
        FromDigits[#, 2]& /@ Reap[
        While[True,
            Sow[a]; a[[m]] = 0;
            If[a[[m - 1]] == 0,
                a[[--m]] = 1, j = m - 1; k = 2*n - 1;
                While[j > 1 && a[[j]] == 1, a[[j--]] = 0; a[[k]] = 1; k -= 2];
                If[j == 1, Break[]];
                a[[j]] = 1; m = 2*n - 1]
        ]][[2, 1]]];
    Join[{{0}, {2}}, Array[alist, 4, 2]] (* Paolo Xausa, Mar 16 2024 *)
  • PARI
    isA014486(n)=my(v=binary(n),t=0);for(i=1,#v,t+=if(v[i],1,-1);if(t<0,return(0))); t==0 \\ Charles R Greathouse IV, Jun 10 2011
    
  • PARI
    a_rows(N) = my(a=Vec([[0]], N)); for(r=1, N-1, my(b=a[r], c=List()); foreach(b, t, my(v=if(t, valuation(t, 2), 0)); for(i=0, v, listput(~c, (t<<2)+(2<Ruud H.G. van Tol, May 16 2024
    
  • Python
    from itertools import count, islice
    from sympy.utilities.iterables import multiset_permutations
    def A014486_gen(): # generator of terms
        yield 0
        for l in count(1):
            for s in multiset_permutations('0'*l+'1'*(l-1)):
                c, m = 0, (l<<1)-1
                for i in range(m):
                    if s[i] == '1':
                        c += 2
                    if cA014486_list = list(islice(A014486_gen(),30)) # Chai Wah Wu, Nov 28 2023
  • SageMath
    def is_A014486(n) :
        B = bin(n)[2::] if n != 0 else 0
        s = 0
        for b in B :
            s += 1 if b=='1' else -1
            if 0 > s : return False
        return 0 == s
    def A014486_list(n): return [k for k in (1..n) if is_A014486(k) ]
    A014486_list(888) # Peter Luschny, Aug 10 2012
    

Extensions

Additional comments from Antti Karttunen, Aug 11 2000 and May 25 2004
Added a(0)=0 (which had been removed in June 2011), Joerg Arndt, Feb 27 2013

A125976 Signature-permutation of Kreweras' 1970 involution on Dyck paths.

Original entry on oeis.org

0, 1, 3, 2, 8, 6, 5, 7, 4, 22, 19, 15, 20, 14, 13, 11, 18, 21, 16, 10, 12, 17, 9, 64, 60, 52, 61, 51, 41, 39, 55, 62, 53, 38, 40, 54, 37, 36, 33, 29, 34, 28, 50, 47, 59, 63, 56, 43, 48, 57, 42, 27, 25, 32, 35, 30, 46, 49, 58, 44, 24, 26, 31, 45, 23, 196, 191, 178, 192, 177
Offset: 0

Views

Author

Antti Karttunen, Jan 02 2007

Keywords

Comments

Lalanne shows in the 1992 paper that this automorphism preserves the sum of peak heights, i.e., that A126302(a(n)) = A126302(n) for all n. Furthermore, he also shows that A126306(a(n)) = A057514(n)-1 and likewise, that A057514(a(n)) = A126306(n)+1, for all n >= 1.
Like A069772, this involution keeps symmetric Dyck paths symmetric, but not necessarily same.
The number of cycles and fixed points in range [A014137(n-1)..A014138(n-1)] of this involution seem to be given by A007595 and the "aerated" Catalan numbers [1, 1, 0, 1, 0, 2, 0, 5, 0, 14, 0, 42, ...], thus this is probably a conjugate of A069770 (as well as of A057163).

Crossrefs

Compositions and conjugations with other automorphisms: A125977-A125979, A125980, A126290.

Formula

a(n) = A080300(A125974(A014486(n))).

A071153 Łukasiewicz word for each rooted plane tree (interpretation e in Stanley's exercise 19) encoded by A014486 (or A063171), with the last leaf implicit, i.e., these words are given without the last trailing zero, except for the null tree which is encoded as 0.

Original entry on oeis.org

0, 1, 20, 11, 300, 201, 210, 120, 111, 4000, 3001, 3010, 2020, 2011, 3100, 2101, 2200, 1300, 1201, 2110, 1210, 1120, 1111, 50000, 40001, 40010, 30020, 30011, 40100, 30101, 30200, 20300, 20201, 30110, 20210, 20120, 20111, 41000, 31001, 31010
Offset: 0

Views

Author

Antti Karttunen, May 14 2002

Keywords

Comments

Note: this finite decimal representation works only up to the 6917th term, as the 6918th such word is already (10,0,0,0,0,0,0,0,0,0). The sequence A071154 shows the initial portion of this sequence sorted.

Examples

			The 11th term of A063171 is 10110010, corresponding to parenthesization ()(())(), thus its Łukasiewicz word is 3010. The 18th term of A063171 is 11011000, corresponding to parenthesization (()(())), thus its Łukasiewicz word is 1201. I.e., in the latter example there is one list on the top-level, which in turn contains two sublists, of which the first is zero elements long and the second is a sublist containing one empty sublist (the last zero is omitted).
		

Crossrefs

For n >= 1, the number of zeros in the term a(n) is given by A057514(n)-1.
The first digit of each term is given by A057515.
Corresponding factorial walk encoding: A071155 (A071157, A071159).
a(n) = A079436(n)/10.

A125985 Signature-permutation of Vaillé's 1997 bijection on 'bridges' (Dyck paths).

Original entry on oeis.org

0, 1, 3, 2, 8, 7, 5, 6, 4, 22, 21, 18, 20, 17, 13, 12, 19, 15, 16, 10, 11, 14, 9, 64, 63, 59, 62, 58, 50, 49, 61, 55, 57, 46, 48, 54, 45, 36, 35, 32, 34, 31, 60, 56, 41, 52, 40, 47, 53, 43, 44, 27, 26, 33, 29, 30, 51, 38, 39, 42, 24, 25, 28, 37, 23, 196, 195, 190, 194, 189
Offset: 0

Views

Author

Antti Karttunen, Jan 02 2007

Keywords

Comments

Vaillé shows in 1997 paper that this automorphism transforms a 'derivation' of a Dyck path to its 'compression', i.e., in OEIS terms, A125985(A126310(n)) = A126309(A125985(n)) holds for all n. He also proves that A057515(A125985(n)) = A126307(n) and A057514(A125985(n)) = A072643(n) - A057514(n) + 1 (the latter identity for all n >= 1).

Crossrefs

Inverse: A125986. The number of cycles, maximum cycle sizes and LCM's of all cycle sizes in range [A014137(n-1)..A014138(n-1)] of this permutation are given by A126291, A126292 and A126293. The fixed points are given by A126300/A126301.

Programs

  • Scheme
    (define (A125985 n) (A080300 (rising-list->binexp (A125985-aux2 (A014486 n)))))
    (define (A125985-aux2 n) (let loop ((lists (A125985-aux1 n)) (z (list)) (m 1)) (if (null? lists) z (loop (cdr lists) (m-join z (car lists) m) (+ m 1)))))
    (define (A125985-aux1 n) (if (zero? n) (list) (let ((begin_from (<< 1 (- (- (A000523 n) (A090996 n)) 1)))) (let loop ((s (A090996 n)) (t 0) (nth_list 1) (p begin_from) (b (if (= 0 (A004198bi n begin_from)) 0 1)) (lists (list (list)))) (cond ((< s 1) (cond ((< p 1) (reverse! lists)) (else (loop (- t (- 1 b)) b (+ 1 nth_list) (>> p 1) (if (= 0 (A004198bi n (>> p 1))) 0 1) (cons (list (+ b 1 nth_list)) lists))))) (else (loop (- s (- 1 b)) (+ t b) nth_list (>> p 1) (if (= 0 (A004198bi n (>> p 1))) 0 1) (cons (cons (+ b nth_list) (car lists)) (cdr lists)))))))))
    (define (A125985-aux2 n) (let loop ((lists (A125985-aux1 n)) (z (list)) (m 1)) (if (null? lists) z (loop (cdr lists) (m-join z (car lists) m) (+ m 1)))))
    (define (m-join a b m) (let loop ((a a) (b b) (c (list))) (cond ((and (not (pair? a)) (not (pair? b))) (reverse! c)) ((not (pair? a)) (loop a (cdr b) (cons (car b) c))) ((not (pair? b)) (loop (cdr a) b (cons (car a) c))) ((equal? (car a) (car b)) (loop (cdr a) (cdr b) (cons (car a) c))) ((> (car b) m) (loop a (cdr b) (cons (car b) c))) (else (loop (cdr a) b (cons (car a) c))))))
    (define (rising-list->binexp rising-list) (let loop ((s 0) (i 0) (h 0) (fs rising-list)) (cond ((null? fs) (+ s (<< (- (<< 1 h) 1) i))) ((> (car fs) h) (loop s (+ i 1) (car fs) (cdr fs))) (else (loop (+ s (<< (- (<< 1 (+ 1 (- h (car fs)))) 1) i)) (+ i 2 (- h (car fs))) (car fs) (cdr fs))))))
    (define (>> n i) (if (zero? i) n (>> (floor->exact (/ n 2)) (- i 1))))
    (define (<< n i) (if (<= i 0) (>> n (- i)) (<< (+ n n) (- i 1))))

A079436 Full Łukasiewicz word for each rooted plane tree (interpretation e in Stanley's exercise 19) encoded by A014486 (or A063171).

Original entry on oeis.org

0, 10, 200, 110, 3000, 2010, 2100, 1200, 1110, 40000, 30010, 30100, 20200, 20110, 31000, 21010, 22000, 13000, 12010, 21100, 12100, 11200, 11110, 500000, 400010, 400100, 300200, 300110, 401000, 301010, 302000, 203000, 202010, 301100, 202100
Offset: 0

Views

Author

Antti Karttunen, Jan 09 2003

Keywords

Comments

Note: Here the last leaf is explicit, i.e. the terms are obtained from those of A071153 by multiplying them by 10.
Note: this finite decimal representation works only up to the 6917th term, as the 6918th such word is already "x0000000000" (where x stands for digit "ten").

Crossrefs

a(n) = 10*A071153(n).
For n > 1, the number of zeros in the term a(n) is given by A057514(n).
The first digit of each term is given by A057515.

A125981 Signature-permutation of Deutsch's 2000 bijection on ordered trees.

Original entry on oeis.org

0, 1, 3, 2, 7, 8, 5, 6, 4, 17, 18, 20, 22, 21, 12, 13, 15, 16, 19, 10, 11, 14, 9, 45, 46, 48, 50, 49, 54, 55, 61, 63, 64, 57, 59, 62, 58, 31, 32, 34, 36, 35, 40, 41, 43, 44, 47, 52, 53, 60, 56, 26, 27, 29, 30, 33, 38, 39, 42, 51, 24, 25, 28, 37, 23, 129, 130, 132, 134, 133
Offset: 0

Views

Author

Antti Karttunen, Jan 02 2007

Keywords

Comments

Deutsch shows in his 2000 paper that this automorphism converts any ordered tree with the number of nodes having degree q to a tree with an equal number of odd-level nodes having degree q-1, from which it follows that, for each positive integer q, the parameters "number of nodes of degree q" and "number of odd-level nodes of degree q-1" are equidistributed. He also shows that this automorphism converts any tree with k leaves to a tree with k even-level nodes, i.e., in OEIS terms, A057514(n) = A126305(A125981(n)).
To obtain the signature permutation, we apply the given Scheme-function *A125981 to the parenthesizations as encoded and ordered by A014486/A063171 (and surrounded by extra pair of parentheses to make a valid Scheme-list) and for each n, we record the position of the resulting parenthesization (after discarding the outermost parentheses from the Scheme-list) in A014486/A063171 and this value will be a(n).

Crossrefs

Inverse: A125982. The number of cycles, maximum cycle sizes and LCM's of all cycle sizes in range [A014137(n-1)..A014138(n-1)] of this permutation seem to be given by A089411, A086586 and A089412, thus this is probably a conjugate of A074683/A074684. A125983 gives the A057163-conjugate.

A126305 a(n) = number of nodes with even distance to the root in the n-th plane general tree encoded by A014486(n). The root node itself is also included.

Original entry on oeis.org

1, 1, 1, 2, 1, 2, 2, 3, 2, 1, 2, 2, 3, 2, 2, 3, 3, 4, 3, 2, 3, 2, 3, 1, 2, 2, 3, 2, 2, 3, 3, 4, 3, 2, 3, 2, 3, 2, 3, 3, 4, 3, 3, 4, 4, 5, 4, 3, 4, 3, 4, 2, 3, 3, 4, 3, 2, 3, 2, 3, 3, 4, 3, 4, 3, 1, 2, 2, 3, 2, 2, 3, 3, 4, 3, 2, 3, 2, 3, 2, 3, 3, 4, 3, 3, 4, 4, 5, 4, 3, 4, 3, 4, 2, 3, 3, 4, 3, 2, 3, 2, 3
Offset: 0

Views

Author

Antti Karttunen, Jan 02 2007

Keywords

Crossrefs

a(n) = A126304(n)+1 = A072643(n)-A126303(n). a(n) = A057514(A125982(n)) for all n >=1.

A126306 a(n) = number of double-rises (UU-subsequences) in the n-th Dyck path encoded by A014486(n).

Original entry on oeis.org

0, 0, 0, 1, 0, 1, 1, 1, 2, 0, 1, 1, 1, 2, 1, 2, 1, 1, 2, 2, 2, 2, 3, 0, 1, 1, 1, 2, 1, 2, 1, 1, 2, 2, 2, 2, 3, 1, 2, 2, 2, 3, 1, 2, 1, 1, 2, 2, 2, 2, 3, 2, 3, 2, 2, 3, 2, 2, 2, 3, 3, 3, 3, 3, 4, 0, 1, 1, 1, 2, 1, 2, 1, 1, 2, 2, 2, 2, 3, 1, 2, 2, 2, 3, 1, 2, 1, 1, 2, 2, 2, 2, 3, 2, 3, 2, 2, 3, 2, 2, 2, 3
Offset: 0

Views

Author

Antti Karttunen, Jan 02 2007

Keywords

Examples

			A014486(20) = 228 (11100100 in binary), encodes the following Dyck path:
    /\
   /..\/\
  /......\
and there is one rising (left-hand side) slope with length 3 and one with length 1, so in the first slope, consisting of 3 U-steps, there are two cases with two consecutive U-steps (overlapping is allowed), thus a(20)=2.
		

Crossrefs

Programs

  • Python
    def ok(n):
        if n==0: return True
        B=bin(n)[2:] if n!=0 else '0'
        s=0
        for b in B:
            s+=1 if b=='1' else -1
            if s<0: return False
        return s==0
    def a014081(n): return sum(((n>>i)&3==3) for i in range(len(bin(n)[2:]) - 1))
    print([a014081(n) for n in range(4001) if ok(n)]) # Indranil Ghosh, Jun 13 2017

Formula

a(n) = A014081(A014486(n)).
a(n) = A000120(A048735(A014486(n))).
a(A125976(n)) = A057514(n)-1, for all n >= 1.

A127284 a(n) = number of valleys (DU-steps) in the Dyck path encoded by A014486(n).

Original entry on oeis.org

0, 0, 1, 0, 2, 1, 1, 1, 0, 3, 2, 2, 2, 1, 2, 1, 2, 2, 1, 1, 1, 1, 0, 4, 3, 3, 3, 2, 3, 2, 3, 3, 2, 2, 2, 2, 1, 3, 2, 2, 2, 1, 3, 2, 3, 3, 2, 2, 2, 2, 1, 2, 1, 2, 2, 1, 2, 2, 2, 1, 1, 1, 1, 1, 0, 5, 4, 4, 4, 3, 4, 3, 4, 4, 3, 3, 3, 3, 2, 4, 3, 3, 3, 2, 4, 3, 4, 4, 3, 3, 3, 3, 2, 3, 2, 3, 3, 2, 3, 3, 3, 2
Offset: 0

Views

Author

Antti Karttunen, Jan 16 2007

Keywords

Examples

			A014486(2) = 10 (1010 in binary) which encodes Dyck path /\/\ with two peaks and one valley, thus a(2)=1.
A014486(12) = 180 (10110100 in binary) which encodes Dyck path:
..../\/\...
./\/....\..
which has two valleys, thus a(12) = 2.
		

Crossrefs

a(A057163(n)) = A126306(n), a(n) = A126306(A057163(n)) for all n. Cf. A057516.

Programs

Formula

a(0)=0, a(n) = A057514(n)-1.

A358550 Depth of the ordered rooted tree with binary encoding A014486(n).

Original entry on oeis.org

1, 2, 2, 3, 2, 3, 3, 3, 4, 2, 3, 3, 3, 4, 3, 3, 3, 3, 4, 4, 4, 4, 5, 2, 3, 3, 3, 4, 3, 3, 3, 3, 4, 4, 4, 4, 5, 3, 3, 3, 3, 4, 3, 3, 3, 3, 4, 4, 4, 4, 5, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 2, 3, 3, 3, 4, 3, 3, 3, 3, 4, 4, 4, 4, 5, 3, 3, 3, 3, 4, 3, 3, 3
Offset: 1

Views

Author

Gus Wiseman, Nov 22 2022

Keywords

Comments

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.

Examples

			The first few rooted trees in binary encoding are:
    0: o
    2: (o)
   10: (oo)
   12: ((o))
   42: (ooo)
   44: (o(o))
   50: ((o)o)
   52: ((oo))
   56: (((o)))
  170: (oooo)
  172: (oo(o))
  178: (o(o)o)
  180: (o(oo))
  184: (o((o)))
		

Crossrefs

Positions of first appearances are A014137.
Leaves of the ordered tree are counted by A057514, standard A358371.
Branches of the ordered tree are counted by A057515.
Edges of the ordered tree are counted by A072643.
The Matula-Goebel number of the ordered tree is A127301.
Positions of 2's are A155587, indices of A020988.
The standard ranking of the ordered tree is A358523.
Nodes of the ordered tree are counted by A358551, standard A358372.
For standard instead of binary encoding we have A358379.
A000108 counts ordered rooted trees, unordered A000081.
A014486 lists all binary encodings.

Programs

  • Mathematica
    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[Depth[bint[k]]-1,{k,Select[Range[0,1000],binbalQ]}]
Showing 1-10 of 12 results. Next