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.

A217710 Cardinality of the set of possible heights of AVL trees with n (leaf-) nodes.

Original entry on oeis.org

1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
Offset: 1

Views

Author

Alois P. Heinz, Mar 20 2013

Keywords

Comments

a(n) increases at Fibonacci numbers (A000045) and decreases at powers of 2 plus 1 (A000051) for n>=8.
a(n) is the height (number of nonzero elements) of column n of triangles A143897, A217298.

Examples

			a(8) = 2: We have 1 AVL tree with n=8 (leaf-) nodes of height 3 and 16 of height 4 (8 is both Fibonacci number and power of 2):
           o              o
         /   \          /   \
       o       o      o       o
      / \     / )    / \     / \
     o   o   o  N   o   o   o   o
    / ) ( ) ( )    ( ) ( ) ( ) ( )
   o  N N N N N    N N N N N N N N
  ( )
  N N
		

Crossrefs

Programs

  • Maple
    a:= proc(n) local j, p; for j from ilog[(1+sqrt(5))/2](n)
           while combinat[fibonacci](j+1)<=n do od;
           p:= ilog2(n);
           j-p-`if`(2^p issqr(t+4) or issqr(t-4))(5*n^2), 1, 0)-
         `if`((t-> is(2^ilog2(t)=t))(n-1), 1, 0))
        end:
    seq(a(n), n=1..120);  # Alois P. Heinz, Aug 14 2021
  • Mathematica
    a[n_] := Module[{j, p}, For[j = Log[(1+Sqrt[5])/2, n] // Floor, Fibonacci[j+1] <= n, j++]; p = Log[2, n] // Floor; j-p-If[2^p < n, 2, 1]]; Table[a[n], {n, 1, 120}] (* Jean-François Alcover, Dec 30 2013, translated from Maple *)

Formula

a(n) = A072649(n) - A029837(n).