A309049 Number T(n,k) of (binary) max-heaps on n elements from the set {0,1} containing exactly k 0's; triangle T(n,k), n>=0, 0<=k<=n, read by rows.
1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 2, 1, 1, 1, 3, 3, 2, 1, 1, 1, 3, 4, 4, 2, 1, 1, 1, 4, 6, 6, 5, 2, 1, 1, 1, 4, 7, 8, 7, 5, 2, 1, 1, 1, 5, 10, 12, 11, 8, 5, 2, 1, 1, 1, 5, 11, 16, 17, 13, 9, 5, 2, 1, 1, 1, 6, 15, 23, 27, 24, 16, 10, 5, 2, 1, 1, 1, 6, 16, 27, 34, 34, 27, 18, 11, 5, 2, 1, 1
Offset: 0
Examples
T(6,0) = 1: 111111. T(6,1) = 3: 111011, 111101, 111110. T(6,2) = 4: 110110, 111001, 111010, 111100. T(6,3) = 4: 101001, 110010, 110100, 111000. T(6,4) = 2: 101000, 110000. T(6,5) = 1: 100000. T(6,6) = 1: 000000. T(7,4) = T(7,7-3) = A000108(3) = 5: 1010001, 1010010, 1100100, 1101000, 1110000. Triangle T(n,k) begins: 1; 1, 1; 1, 1, 1; 1, 2, 1, 1; 1, 2, 2, 1, 1; 1, 3, 3, 2, 1, 1; 1, 3, 4, 4, 2, 1, 1; 1, 4, 6, 6, 5, 2, 1, 1; 1, 4, 7, 8, 7, 5, 2, 1, 1; 1, 5, 10, 12, 11, 8, 5, 2, 1, 1; 1, 5, 11, 16, 17, 13, 9, 5, 2, 1, 1; 1, 6, 15, 23, 27, 24, 16, 10, 5, 2, 1, 1; 1, 6, 16, 27, 34, 34, 27, 18, 11, 5, 2, 1, 1; ...
Links
- Alois P. Heinz, Rows n = 0..200, flattened
- Eric Weisstein's World of Mathematics, Heap
- Wikipedia, Binary heap
Crossrefs
Programs
-
Maple
b:= proc(n) option remember; `if`(n=0, 1, (g-> (f-> expand( x^n+b(f)*b(n-1-f)))(min(g-1, n-g/2)))(2^ilog2(n))) end: T:= n-> (p-> seq(coeff(p, x, i), i=0..n))(b(n)): seq(T(n), n=0..14);
-
Mathematica
b[n_] := b[n] = If[n == 0, 1, Function[g, Function[f, Expand[x^n + b[f]*b[n - 1 - f]]][Min[g - 1, n - g/2]]][2^Floor[Log[2, n]]]]; T[n_] := Function[p, Table[Coefficient[p, x, i], {i, 0, n}]][b[n]]; T /@ Range[0, 14] // Flatten (* Jean-François Alcover, Oct 04 2019, after Alois P. Heinz *)
Comments