OFFSET
1,1
FORMULA
Conjectures from Colin Barker, Dec 09 2014: (Start)
a(n) = (3*2^n+2^(1+2*n)-5)/3.
a(n) = 6*a(n-1)-7*a(n-2)-6*a(n-3)+8*a(n-4).
G.f.: x*(8*x-3) / ((x-1)*(2*x-1)*(4*x-1)).
(End)
EXAMPLE
For a complete binary tree with 2 levels (root, level-1, level-2), the total number of node pairs is 7 choose 2 = 21, whereas the number of node pairs that are at levels which are at an absolute difference of less than 2 from each other are 13.
PROG
(Python)
def nc2(n):
return n * (n-1) / 2
def numAdjacentNodes(levels):
ret = 0
for level in range(1, levels+1):
ret += ((1 << level) + nc2(1 << level))
return ret
for height in range(1, 33):
print numAdjacentNodes(height)
CROSSREFS
KEYWORD
nonn
AUTHOR
Dhruv Matani, Dec 07 2014
STATUS
approved