skp
BAN USER@messiah, i meant the first node with no-more left sub-tree to be the left-most right cousin. My mistake, this would not necessarily be the leaf node.
To my understanding: To reach the left most right cousin, you need to explore the entire right sub-tree of the given node's parent. (This helps me find the 'right' cousin). Further, in this right sub-tree we are interested in finding the left most node, which can be reached by exploring the left subtree, hence in-order. If you look at such a subtree, the left most (visual node)is always reachable through inorder traversal.
1. Find the root of the given "node" [ long n]. While doing so keep a track of the parent node.
2. Once found. Run a In-order traversal from the parent node found in step 1.
3. The first leaf node in the in-order traversal would be left-most right cousin.
time-complexity [ O(logN)
String literals are treated as constant strings, so, in summary you can't change them. If you run strings <binary> you'll see abc as such stored in the BSS section of the binary. So, any attempt to modify a constant memory location would result in an undefined behaviour or crash.
- skp March 26, 2012
Here's the driver program for the same.
Assumptions : Alphabet [a-z] are used
digits [1-9]
- skp March 01, 2013