an improvement to above solution

take a dynamic linear array structure storing (<node name> and y-index) and
whose index tells x value of <NodeName>

Algo:>  do inorder traversal and when reach the leftmost end of the tree
start updating the structure.



On Wed, Aug 24, 2011 at 1:53 AM, DK <[email protected]> wrote:

> 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.
>



-- 
*Shashi Kant *
***"Think positive and find fuel in failure"*
*+919002943948*
Final Yr. Cse ,Undergraduate Student,
*National Institute Of Technology Durgapur.*

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
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.

Reply via email to