login
Number of (binary) heaps of length n whose element set equals [k], where k is chosen so as to maximize this number.
2

%I #19 Jun 14 2024 11:11:06

%S 1,1,1,3,7,23,92,502,1880,12008,66730,516610,3194229,29181056,

%T 224463264,2481941592,18805353654,203330533890,1845535279170,

%U 25328291231632,244141112078994,3361871786122320,39998248932957744,674899378544965360,7394457611253245344

%N Number of (binary) heaps of length n whose element set equals [k], where k is chosen so as to maximize this number.

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

%H Alois P. Heinz, <a href="/A373608/b373608.txt">Table of n, a(n) for n = 0..495</a>

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

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

%F a(n) = max({ A373451(n,k) : 0 <= k <= n }).

%e a(4) = 7: 3121, 3211, 3212, 3221, 3231, 3312, 3321 (with k=3).

%e a(6) = 92: 413112, 423111, 423112, 423113, 423121, 423122, 423123, ..., 443421, 444123, 444132, 444213, 444231, 444312, 444321 (with k=4).

%e a(7) = 502: 5141123, 5141132, 5241113, 5241123, 5241131, 5241132, 5241133, ..., 5553421, 5554123, 5554132, 5554213, 5554231, 5554312, 5554321 (with k=5).

%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-> max(seq(T(n, k), k=0..n)):

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

%Y Row maxima of A373451.

%Y Cf. A002869.

%K nonn

%O 0,4

%A _Alois P. Heinz_, Jun 10 2024