Consider a full binary tree of n nodes numbered from 1 to n in the common top-down left-to-right manner. For the sake of the question, we can consider the following tree:
1
/ \
2 3
/ \ / \
4 5 6 7
I need to traverse from the root to some other node. Let's say I need to traverse to 6.
Because I can see it from the picture, I know I have to go right to 3 and then left to 6. But I need to be able to find that out mathematically without a picture.
When I am in the root, how do I know that 6 is in the right sub-tree and not in the left one? And then when I am in 3, how do I know that 6 is in the left sub-tree and not in the left one?
1if I want to reach6. – zbr Mar 11 '15 at 16:08