login
Number T(n,k) of defective (binary) heaps on n elements from the set {0,1} where k ancestor-successor pairs do not have the correct order; triangle T(n,k), n>=0, read by rows.
7

%I #25 May 09 2024 02:52:20

%S 1,2,3,1,5,2,1,7,4,3,2,11,6,7,5,2,1,16,13,12,8,10,3,2,26,22,23,14,21,

%T 10,9,2,1,36,36,39,33,33,28,26,13,9,2,1,56,54,67,61,60,59,56,37,34,11,

%U 13,2,2,81,99,111,96,117,112,107,96,76,53,36,20,14,4,2

%N Number T(n,k) of defective (binary) heaps on n elements from the set {0,1} where k ancestor-successor pairs do not have the correct order; triangle T(n,k), n>=0, read by rows.

%C T(n,k) is the number of bit vectors v of length n having exactly k pairs (i,j) in {1,...,n} X {1,...,floor(log_2(i))} such that v[i] > v[floor(i/2^j)].

%C T(n,0) counts perfect (binary) heaps on n elements from the set {0,1}.

%C T(n,k) is defined for all n>=0 and k>=0. The triangle displays only positive terms. All other terms are zero.

%H Alois P. Heinz, <a href="/A372640/b372640.txt">Rows n = 0..112, flattened</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>

%e T(4,0) = 7: 0000, 1000, 1010, 1100, 1101, 1110, 1111.

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

%e T(4,2) = 3: 0001, 0101, 0110.

%e T(4,3) = 2: 0011, 0111.

%e (The examples use max-heaps.)

%e Triangle T(n,k) begins:

%e 1;

%e 2;

%e 3, 1;

%e 5, 2, 1;

%e 7, 4, 3, 2;

%e 11, 6, 7, 5, 2, 1;

%e 16, 13, 12, 8, 10, 3, 2;

%e 26, 22, 23, 14, 21, 10, 9, 2, 1;

%e 36, 36, 39, 33, 33, 28, 26, 13, 9, 2, 1;

%e 56, 54, 67, 61, 60, 59, 56, 37, 34, 11, 13, 2, 2;

%e 81, 99, 111, 96, 117, 112, 107, 96, 76, 53, 36, 20, 14, 4, 2;

%e ...

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

%p 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)))

%p end:

%p T:= n-> (p-> seq(coeff(p, x, i), i=0..degree(p)))(b(n, 0)):

%p seq(T(n), n=0..14);

%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 T[n_] := CoefficientList[b[n, 0], x];

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

%Y Columns k=0-1 give: A091980(n+1), A372643.

%Y Row sums give A000079.

%Y Main diagonal gives A372641.

%Y T(2,n) gives A372642.

%Y Cf. A306393, A370484.

%K nonn,tabf

%O 0,2

%A _Alois P. Heinz_, May 08 2024