OFFSET
0,3
COMMENTS
Also the total number of 0's in all (binary) min-heaps on n elements from the set {0,1}.
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..5631
Eric Weisstein's World of Mathematics, Heap
Wikipedia, Binary heap
FORMULA
EXAMPLE
a(4) = 15 = 0+1+2+2+3+3+4, the total number of 1's in 0000, 1000, 1010, 1100, 1101, 1110, 1111.
MAPLE
b:= proc(n) option remember; `if`(n=0, 1, (g-> (f-> expand(
1+x*b(f)*b(n-1-f)))(min(g-1, n-g/2)))(2^ilog2(n)))
end:
a:= n-> subs(x=1, diff(b(n), x)):
seq(a(n), n=0..40);
MATHEMATICA
b[n_][x_] := b[n][x] = If[n == 0, 1, Function[g, Function[f, Expand[1 + x b[f][x] b[n - 1 - f][x]]][Min[g - 1, n - g/2]]][2^(Length[IntegerDigits[ n, 2]] - 1)]];
a[n_] := b[n]'[1];
a /@ Range[0, 40] (* Jean-François Alcover, Apr 22 2021, after Alois P. Heinz *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Alois P. Heinz, Jul 09 2019
STATUS
approved