A245905 Zero followed by the terms of A023705 arranged to give the unique path to the n-th node of a complete, rooted and ordered ternary tree.
0, 1, 2, 3, 5, 9, 13, 6, 10, 14, 7, 11, 15, 21, 37, 53, 25, 41, 57, 29, 45, 61, 22, 38, 54, 26, 42, 58, 30, 46, 62, 23, 39, 55, 27, 43, 59, 31, 47, 63, 85, 149, 213, 101, 165, 229, 117, 181, 245, 89, 153, 217, 105, 169, 233, 121, 185, 249, 93, 157, 221, 109, 173, 237, 125, 189, 253
Offset: 1
Keywords
Examples
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.
Links
- Adrian Rusu, Tree Drawing Algorithms, Rowan University.
- Eric Weisstein's World of Mathematics, Complete Ternary Tree.
Crossrefs
Cf. A023705.
Programs
-
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}]
Comments