login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
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
Wikipedia, AVL tree
FORMULA
a(n) = A072649(n) - A029837(n).
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:
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 *)
CROSSREFS
Sequence in context: A211353 A094189 A122771 * A112190 A112188 A112189
KEYWORD
nonn
AUTHOR
Alois P. Heinz, Mar 20 2013
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 19 23:40 EDT 2024. Contains 371798 sequences. (Running on oeis4.)