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.

A227822 Number of permutations of [n], [n+1], ... that result in a binary search tree of height n.

This page as a plain text file.
%I A227822 #25 Apr 02 2021 02:46:16
%S A227822 1,1,4,220,60092152,203720181459953921762400,
%T A227822 7088043372247785801830314829178419617696182324188730917543544992
%N A227822 Number of permutations of [n], [n+1], ... that result in a binary search tree of height n.
%C A227822 Empty external nodes are counted in determining the height of a search tree.
%H A227822 Alois P. Heinz, <a href="/A227822/b227822.txt">Table of n, a(n) for n = 0..9</a>
%H A227822 Wikipedia, <a href="https://en.wikipedia.org/wiki/Binary_search_tree">Binary search tree</a>
%H A227822 <a href="/index/Ro#rooted">Index entries for sequences related to rooted trees</a>
%H A227822 <a href="/index/Tra#trees">Index entries for sequences related to trees</a>
%F A227822 a(n) = Sum_{k=n..2^n-1} A195581(k,n).
%e A227822 a(2) = 4, because 4 permutations of {1,2}, {1,2,3}, ... result in a binary search tree of height 2:
%e A227822   (1,2):   1      (2,1):   2    (2,1,3), (2,3,1):    2
%e A227822           / \             / \                      /   \
%e A227822          o   2           1   o                    1     3
%e A227822             / \         / \                      / \   / \
%e A227822            o   o       o   o                    o   o o   o
%p A227822 b:= proc(n, k) option remember; `if`(n<2, `if`(k<n, 0, 1),
%p A227822       add(binomial(n-1, r)*b(r, k-1)*b(n-1-r, k-1), r=0..n-1))
%p A227822     end:
%p A227822 a:= n-> add(b(k, n)-b(k, n-1), k=n..2^n-1):
%p A227822 seq(a(n), n=0..6);
%t A227822 b[n_, k_] := b[n, k] = If[n < 2, If[k < n, 0, 1],
%t A227822    Sum[Binomial[n - 1, r]*b[r, k - 1]*b[n - 1 - r, k - 1], {r, 0, n - 1}]];
%t A227822 a[n_] := Sum[b[k, n] - b[k, n - 1], {k, n, 2^n - 1}];
%t A227822 a /@ Range[0, 6] (* _Jean-François Alcover_, Apr 02 2021, after _Alois P. Heinz_ *)
%Y A227822 Column sums of A195581 and of A244108.
%Y A227822 Cf. A317012.
%K A227822 nonn
%O A227822 0,3
%A A227822 _Alois P. Heinz_, Jul 31 2013
%E A227822 Terms corrected by _Alois P. Heinz_, Dec 08 2015