|
|
A374811
|
|
Numerator of the expected height of a random binary search tree (BST) with n elements.
|
|
0
|
|
|
-1, 0, 1, 5, 7, 14, 49, 1156, 2531, 2461, 5263, 23231, 48857, 142327, 161366, 677983151, 701098187, 49162215523, 56895744916, 97659246406291, 28593399072431, 21502630803250973, 26851741349945933, 246602936364321931, 1508124176077531039, 10968493811640186469
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,4
|
|
COMMENTS
|
Here we're using the conventional definition of BST height, which is path length from the root to the node (the height of an empty tree is -1), as compared to A195582 which has the height one greater.
|
|
LINKS
|
|
|
FORMULA
|
|
|
MAPLE
|
b:= proc(n, k) option remember;
if n=0 then 1
elif n=1 then `if`(k>0, 1, 0)
else add(binomial(n-1, r-1) *b(r-1, k-1) *b(n-r, k-1), r=1..n)
fi
end:
T:= (n, k)-> b(n, k)-`if`(k>0, b(n, k-1), 0):
a:= n-> add(T(n, k)*k, k=0..n)/n!:
seq(numer(a(n)-1), n=0..30);
|
|
MATHEMATICA
|
[n_, k_] := b[n, k] = If[n==0, 1, If[n==1, If[k>0, 1, 0], Sum[Binomial[n - 1, r-1]*b[r-1, k-1]*b[n-r, k-1], {r, 1, n}]]]; T[n_, k_] := b[n, k] - If[ k>0, b[n, k-1], 0]; a[n_] := Sum[T[n, k]*k, {k, 0, n}]/n!; Table[ Numerator[a[n]-1], {n, 0, 30}]
|
|
CROSSREFS
|
|
|
KEYWORD
|
sign,frac,new
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|