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.

A316944 Total height of the binary search trees summed over all permutations of [n].

This page as a plain text file.
%I A316944 #18 Jan 27 2021 10:13:41
%S A316944 0,1,4,16,80,456,3072,23536,202304,1937920,20470400,236172288,
%T A316944 2955465216,39893618688,577937479680,8944476580864,147277509541888,
%U A316944 2570740210700288,47418288632692736,921669646969167872,18829500772271472640,403390045252173381632
%N A316944 Total height of the binary search trees summed over all permutations of [n].
%C A316944 Each permutation of [n] generates a binary search tree of height h (floor(log_2(n))+1 <= h <= n) when its elements are inserted in that order into the initially empty tree.  The average height of a binary search tree on n elements is A195582(n)/A195583(n).
%C A316944 Empty external nodes are counted in determining the height of a search tree.
%H A316944 Alois P. Heinz, <a href="/A316944/b316944.txt">Table of n, a(n) for n = 0..449</a>
%H A316944 Wikipedia, <a href="https://en.wikipedia.org/wiki/Binary_search_tree">Binary search tree</a>
%H A316944 <a href="/index/Ro#rooted">Index entries for sequences related to rooted trees</a>
%H A316944 <a href="/index/Tra#trees">Index entries for sequences related to trees</a>
%F A316944 a(n) = Sum_{k=0..n} k * A195581(n,k) = Sum_{k=0..n} k * A244108(n,k).
%F A316944 a(n) = A000142(n) * A195582(n)/A195583(n).
%e A316944 a(3) = 16 = 3 + 3 + (2+2) + 3 + 3:
%e A316944 .
%e A316944           3         3        2        1         1
%e A316944          / \       / \      / \      / \       / \
%e A316944         2   o     1   o    1   3    o   3     o   2
%e A316944        / \       / \      ( ) ( )      / \       / \
%e A316944       1   o     o   2     o o o o     2   o     o   3
%e A316944      / \           / \               / \           / \
%e A316944     o   o         o   o   (2,1,3)   o   o         o   o
%e A316944      (3,2,1)     (3,1,2)  (2,3,1)    (1,3,2)   (1,2,3)
%e A316944 .
%p A316944 b:= proc(n, k) option remember; `if`(n<2, `if`(k<n, 0, 1),
%p A316944       add(binomial(n-1, r)*b(r, k-1)*b(n-1-r, k-1), r=0..n-1))
%p A316944     end:
%p A316944 a:= n-> add(k*(b(n, k)-b(n, k-1)), k=0..n):
%p A316944 seq(a(n), n=0..25);
%t A316944 b[n_, k_] := b[n, k] = If[n < 2, If[k < n, 0, 1], Sum[Binomial[n - 1, r]* b[r, k - 1] b[n - 1 - r, k - 1], {r, 0, n - 1}]];
%t A316944 a[n_] := Sum[k(b[n, k] - b[n, k - 1]), {k, 0, n}];
%t A316944 a /@ Range[0, 25] (* _Jean-François Alcover_, Jan 27 2021, after _Alois P. Heinz_ *)
%Y A316944 Cf. A000142, A000523, A195581, A195582, A195583, A244108, A335921.
%K A316944 nonn
%O A316944 0,3
%A A316944 _Alois P. Heinz_, Jul 17 2018