OFFSET
0,3
COMMENTS
The binary tree has root node 0, in row n=0. The left child is m - n and the right child is m + n, where m is the parent node and n is the row of the child. A given node will only have a child if the child is nonnegative and the value of the child is not present in the path from the parent to the root, including the root value itself.
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..9517 (rows for n = 0..21 flattened)
EXAMPLE
The binary tree starts with root 0 in row n = 0. In row n = 3, the parent node m = 3 does not have a left child since 3 - 3 = 0 is included in the path from the parent to the root {3,1,0}.
The tree begins:
row
[n]
[0] 0
\
[1] 1
\
[2] 3
\
[3] __6__
/ \
[4] 2 10
\ / \
[5] 7 5 15
PROG
(MATLAB)
function a = A360255( max_row )
p = 0; a = 0; pos = 1;
for n = 1:max_row
for k = pos:length(a)
h =[]; o = p(k);
while o > 0
h = [h a(o)]; o = p(o);
end
if a(k)-n > 0
if isempty(find(h == a(k)-n, 1))
p = [p k]; a = [a a(k)-n];
end
end
if isempty(find(h == a(k)+n, 1))
p = [p k]; a = [a a(k)+n];
end
end
pos = k+1;
end
end % Thomas Scheuerle, Jan 31 2023
CROSSREFS
KEYWORD
nonn,tabf
AUTHOR
John Tyler Rascoe, Jan 30 2023
STATUS
approved