login
Number of defective (binary) heaps on n elements from the set {0,1} where exactly one ancestor-successor pair does not have the correct order.
4

%I #16 May 09 2024 15:56:29

%S 0,0,1,2,4,6,13,22,36,54,99,164,260,400,692,1146,1730,2638,4358,7148,

%T 10788,16716,27168,44692,65630,100736,159851,261156,385740,599704,

%U 946368,1551686,2245014,3455650,5364990,8743620,12757292,19869332,30818816,50429524

%N Number of defective (binary) heaps on n elements from the set {0,1} where exactly one ancestor-successor pair does not have the correct order.

%H Alois P. Heinz, <a href="/A372643/b372643.txt">Table of n, a(n) for n = 0..5636</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) = A372640(n,1).

%e a(2) = 1: 01.

%e a(3) = 2: 001, 010.

%e a(4) = 4: 0010, 0100, 1001, 1011.

%e a(5) = 6: 00100, 01000, 10001, 10010, 10101, 10110.

%e a(6) = 13: 001000, 010000, 100001, 100010, 100100, 101010, 101011, 101100, 101101, 110001, 110011, 110101, 110111.

%e (The examples use max-heaps.)

%p b:= proc(n, t) option remember; convert(series(`if`(n=0, 1, (g->

%p (f-> expand(b(f, t)*b(n-1-f, t)*x^t+b(f, t+1)*b(n-1-f, t+1)

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

%p end:

%p a:= n-> coeff(b(n, 0),x,1):

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

%t b[n_, t_] := b[n, t] = If[n == 0, 1, Function[g, Function [f,

%t Expand[b[f, t]*b[n - 1 - f, t]*x^t + b[f, t + 1]*b[n - 1 - f, t + 1]]][

%t Min[g - 1, n - g/2]]][2^(Length@IntegerDigits[n, 2] - 1)]];

%t a[n_] := Coefficient[b[n, 0], x, 1];

%t Table[a[n], {n, 0, 39}] (* _Jean-François Alcover_, May 09 2024, after _Alois P. Heinz_ *)

%Y Column k=1 of A372640.

%Y Cf. A323957, A372628.

%K nonn

%O 0,4

%A _Alois P. Heinz_, May 08 2024