|
|
A217710
|
|
Cardinality of the set of possible heights of AVL trees with n (leaf-) nodes.
|
|
6
|
|
|
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
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,8
|
|
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.
|
|
LINKS
|
|
|
FORMULA
|
|
|
EXAMPLE
|
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
|
|
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<n, 2, 1)
end:
seq(a(n), n=1..120);
# second Maple program:
a:= proc(n) option remember; `if`(n=0, 1, a(n-1)+
`if`((t-> issqr(t+4) or issqr(t-4))(5*n^2), 1, 0)-
`if`((t-> is(2^ilog2(t)=t))(n-1), 1, 0))
end:
|
|
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 *)
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|