login
Number of (binary) heaps where n is the sum of their length and the size of the element set [k].
3

%I #20 Feb 16 2025 08:34:06

%S 1,0,1,1,2,4,8,17,41,103,282,792,2239,6680,21143,70647,245357,871255,

%T 3202552,12334046,49635128,205403510,856780528,3601169551,15507530896,

%U 69267381313,320345619798,1518428936730,7345400773513,36469929240960,186875135258481

%N Number of (binary) heaps where n is the sum of their length and the size of the element set [k].

%C These heaps may contain repeated elements. Their element sets are gap-free and contain 1 (if nonempty).

%H Alois P. Heinz, <a href="/A373632/b373632.txt">Table of n, a(n) for n = 0..710</a>

%H Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/Heap.html">Heap</a>

%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Binary_heap">Binary heap</a>

%F a(n) = Sum_{j=0..floor(n/2)} A373451(n-j,j).

%e a(0) = 1: the empty heap.

%e a(2) = 1: 1.

%e a(3) = 1: 11.

%e a(4) = 2: 111, 21.

%e a(5) = 4: 1111, 211, 212, 221.

%e a(6) = 8: 11111, 2111, 2121, 2211, 2212, 2221, 312, 321.

%e a(7) = 17: 111111, 21111, 21211, 22111, 22112, 22121, 22122, 22211, 22212, 22221, 3121, 3211, 3212, 3221, 3231, 3312, 3321.

%e (The examples use max-heaps.)

%p b:= proc(n, k) option remember; `if`(n=0, 1,

%p (g-> (f-> add(b(f, j)*b(n-1-f, j), j=1..k)

%p )(min(g-1, n-g/2)))(2^ilog2(n)))

%p end:

%p T:= (n, k)-> add(binomial(k, j)*(-1)^j*b(n, k-j), j=0..k):

%p a:= n-> add(T(n-j, j), j=0..n/2):

%p seq(a(n), n=0..30);

%Y Antidiagonal sums of A373451.

%K nonn

%O 0,5

%A _Alois P. Heinz_, Jun 11 2024