start traversing the tree, keep two vectors, one for +verticals and one for
negative verticals( root at vertical 0, its left is at vertical -1, and
right on vertical +1)

keep adding nodes' data into appropriate vector's appropriate index.

Best Regards
Ashish Goel
"Think positive and find fuel in failure"
+919985813081
+919966006652


On Thu, Jan 19, 2012 at 8:41 PM, Coding Geek <[email protected]> wrote:

> Given a binary tree with no size limitation, write a program to find the
> sum of each vertical level and store the result in an appropriate
> data structure (Note: You cannot use an array as the tree can be of any
> size).
>
>                                                      4
>                                                  /       \
>                                                7          8
>                                            /      \      /  \
>                                          10      11 /     13
>                                                    12
>
> here 4(root) , 11(leftsubtree's right child ), 12 (rightsubtree's
> left child) are in same vertical Line
>
>
> so here vertical line 1 is from 10
> vertical line 2 sum is 7
>
> vertical line  3 sum is 4+11+12=27 (May Have Some Doubt So i Have
> represented the figure in correct way)
>
> vertical line  4 is 8
> vertical line  5 is 13
>
>
>
>
>
> --
>
> "To Iterate is Human, To Recurse is Divine"
>
>
>
>  --
> 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.
>

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