Let Left = -1, Right = +1
For each node Set:
X = Sigma{Left or Right for each node on the path from root to node}
Y = -Depth of the node in the tree
Go through the tree once and set X and Y values using any traversal (say
postorder) in an array.
Also, during that traversal, find max_height and the number of nodes in the
left subtree of root.
Go through the array and output: <Node Name> (<X + num_left_nodes_of_root>,
<Y + max_height>)
--
DK
http://gplus.to/divyekapoor
http://twitter.com/divyekapoor
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/algogeeks/-/qp4FZ3vE5WcJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.