OFFSET
1,3
COMMENTS
There is no path to the root node so first node path is 0. All other paths are represented by the terms of A023705 that are base 4 numbers containing no zeros. Starting at the lowest order digit base 4, if this is 1 then the path from the root node is to the left, if it is 2 straight on and if it is 3 to the right. Each successive digit order defines the next path to be taken until the highest digit order is reached and the specified node found.
LINKS
Adrian Rusu, Tree Drawing Algorithms, Rowan University.
Eric Weisstein's World of Mathematics, Complete Ternary Tree.
EXAMPLE
a(33)=39, so the path to the 33rd node is given by 39 and when represented as the base 4 number gives 213. Hence the path to the 33rd node from the root node is Right, Left, Straight.
MATHEMATICA
tree=3; nest[{m2_, p2_}] := If[(mod=Mod[m2, tree])>1, (ind=mod-1; {(m2+tree-mod)/tree, ind+p2*(tree+1)}), (ind=tree+mod-1; {(m2-mod)/tree, ind+p2*(tree+1)})]; Table[NestWhile[nest, {n, 0}, #[[1]]!=1 &][[2]], {n, 1, 100}]
CROSSREFS
KEYWORD
nonn
AUTHOR
Frank M Jackson, Nov 13 2014
STATUS
approved