OFFSET
1,1
COMMENTS
When an infinite planar binary tree is mapped breadth-first-wise from left to right (1 is at top, 2 is its left and 3 its right child, 4 is 2's left child, etc.) then this permutation induces such rearrangement of its nodes, that on the right side every node replaces its right child, on the left side the left children replace their parents and the right children are reflected to the right side, to be the left children of their new parents.
LINKS
MAPLE
RightChildInverted := proc(n) local k; if(1 = n) then RETURN(3); fi; k := floor_log_2(n)-1; if(3 = floor(n/(2^k))) then RETURN((2*n)+1); fi; if(0 = (n mod 2)) then RETURN(n/2); fi; RETURN(2^(k+1) + ((2^(k+2))-1) - n); end;
CROSSREFS
KEYWORD
nonn
AUTHOR
Antti Karttunen, Oct 28 2001
STATUS
approved