Re: [algogeeks] Vertical Sum in a given Binary Tree

2012-03-20 Thread rahul sharma
we have to include every node??if distance for two or more nodes is same they are summed???m i ryt???i doubt On Mon, Mar 19, 2012 at 9:36 PM, shady sinv...@gmail.com wrote: oops no 2 there On Mon, Mar 19, 2012 at 9:36 PM, shady sinv...@gmail.com wrote: if tree is like 1 / \ 2 3 / \ / \ 4

Re: [algogeeks] Vertical Sum in a given Binary Tree

2012-03-20 Thread shady
yes, that's what he wrote in the definition of vertical sum as well. On Tue, Mar 20, 2012 at 10:24 PM, rahul sharma rahul23111...@gmail.comwrote: we have to include every node??if distance for two or more nodes is same they are summed???m i ryt???i doubt On Mon, Mar 19, 2012 at 9:36 PM,

Re: [algogeeks] Vertical Sum in a given Binary Tree

2012-03-20 Thread rahul sharma
ohk...thnx all... On Tue, Mar 20, 2012 at 11:03 PM, shady sinv...@gmail.com wrote: yes, that's what he wrote in the definition of vertical sum as well. On Tue, Mar 20, 2012 at 10:24 PM, rahul sharma rahul23111...@gmail.comwrote: we have to include every node??if distance for two or more

Re: [algogeeks] Vertical Sum in a given Binary Tree

2012-03-20 Thread rahul sharma
ohk...thnx all... On Tue, Mar 20, 2012 at 11:03 PM, shady sinv...@gmail.com wrote: yes, that's what he wrote in the definition of vertical sum as well. On Tue, Mar 20, 2012 at 10:24 PM, rahul sharma rahul23111...@gmail.comwrote: we have to include every node??if distance for two or more

Re: [algogeeks] Vertical Sum in a given Binary Tree

2012-03-19 Thread srikanth reddy malipatel
hii supraja can u mail me the link for your blog plz. On Sun, Mar 18, 2012 at 6:38 PM, Supraja Jayakumar suprajasank...@gmail.com wrote: Hi Others are also welcome to comment on the code. If links are allowed in algogeeks, I might send my wordpress blog link that explains this problem in

Re: [algogeeks] Vertical Sum in a given Binary Tree

2012-03-19 Thread shady
nice explanation aman and prashant 1(0) / \ 2(-1) 3(1) / \ / \ 4(-2) 5(0) 6(0) 7(2) As you see this example, each node has an extra attribute(not necessary though) which tells its distance from the root node. Take map and as you traverse the tree in any order, add the count to the map value.

Re: [algogeeks] Vertical Sum in a given Binary Tree

2012-03-19 Thread shady
anything that can help people learn is always allowed. :) On Sun, Mar 18, 2012 at 6:38 PM, Supraja Jayakumar suprajasank...@gmail.com wrote: Hi Others are also welcome to comment on the code. If links are allowed in algogeeks, I might send my wordpress blog link that explains this problem

Re: [algogeeks] Vertical Sum in a given Binary Tree

2012-03-19 Thread rahul sharma
@supraja ..can u give example..code not needed.. @all..plz post me example.i dnt know what is vertical sum..i wana know only that..thnx... On Mon, Mar 19, 2012 at 7:31 PM, shady sinv...@gmail.com wrote: anything that can help people learn is always allowed. :) On Sun, Mar 18, 2012 at 6:38

Re: [algogeeks] Vertical Sum in a given Binary Tree

2012-03-19 Thread shady
if tree is like 1 / \ 2 3 / \ / \ 4 5 6 7 / \ 12 -8 then vertical sums are 12(1 + 5 + 6) 2 4 -6(2+-8) 3 7 12 On Mon, Mar 19, 2012 at 9:05 PM, rahul sharma rahul23111...@gmail.comwrote: @supraja ..can u give example..code not needed.. @all..plz post me example.i dnt know what is vertical

Re: [algogeeks] Vertical Sum in a given Binary Tree

2012-03-19 Thread shady
oops no 2 there On Mon, Mar 19, 2012 at 9:36 PM, shady sinv...@gmail.com wrote: if tree is like 1 / \ 2 3 / \ / \ 4 5 6 7 / \ 12 -8 then vertical sums are 12(1 + 5 + 6) 2 4 -6(2+-8) 3 7 12 On Mon, Mar 19, 2012 at 9:05 PM, rahul sharma rahul23111...@gmail.comwrote: @supraja

Re: [algogeeks] Vertical Sum in a given Binary Tree

2012-03-18 Thread rahul sharma
plz some one explain...i hav read online but getting the code and same explanaiton...need it urgent...thnx in advance On Sun, Mar 18, 2012 at 12:38 AM, rahul sharma rahul23111...@gmail.comwrote: @anna..plz elaborate more... On Sun, Mar 18, 2012 at 12:26 AM, Supraja Jayakumar

Re: [algogeeks] Vertical Sum in a given Binary Tree

2012-03-18 Thread Supraja Jayakumar
Hi Others are also welcome to comment on the code. If links are allowed in algogeeks, I might send my wordpress blog link that explains this problem in detail and in picture. BinaryTree* VerticalSum(BinaryTree *bt) { if(!bt) return; BinaryTree *left = bt-left; BinaryTree *right = bt-right;

[algogeeks] Vertical Sum in a given Binary Tree

2012-03-17 Thread rahul sharma
what is vertical sum in binayr tree...i dnt need the algo for this..just need the concept...that what is vertical sum??? Given a Binary Tree, find vertical sum of the nodes that are in same vertical line. Print all sums through different vertical lines. Examples: 1 / \ 2 3

Re: [algogeeks] Vertical Sum in a given Binary Tree

2012-03-17 Thread Aman Raj
Vertical sum is sum of all the nodes that are present in same horizontal distance from the root. In the example quoted by you the root 1 is at 0 Horizontal distance from root, while its children are both -1 and +1 distance from root. Now take the case of 1,5 and 6, 1 being the root is at 0

Re: [algogeeks] Vertical Sum in a given Binary Tree

2012-03-17 Thread prashant thorat
First , Do recursive traverse from root node and assign vertical level for each node. like this, for root node level = 0 , root-left level = -1 , root-left-right = 0 , root-left-left = -2, like this so below tree becomes, 1(0) /\ 2(-1)3(1) / \ /

Re: [algogeeks] Vertical Sum in a given Binary Tree

2012-03-17 Thread rahul sharma
how come 2,3,7 in vertical sum? On Sat, Mar 17, 2012 at 3:48 PM, prashant thorat prashantnit...@gmail.comwrote: First , Do recursive traverse from root node and assign vertical level for each node. like this, for root node level = 0 , root-left level = -1 , root-left-right = 0 ,

Re: [algogeeks] Vertical Sum in a given Binary Tree

2012-03-17 Thread rahul sharma
plz explain...i m nt able to get the concept. On Sat, Mar 17, 2012 at 8:50 PM, rahul sharma rahul23111...@gmail.comwrote: how come 2,3,7 in vertical sum? On Sat, Mar 17, 2012 at 3:48 PM, prashant thorat prashantnit...@gmail.com wrote: First , Do recursive traverse from root node and

Re: [algogeeks] Vertical Sum in a given Binary Tree

2012-03-17 Thread Supraja Jayakumar
Hi I think its the sum of all the right children of the left subtree and left children of the right subtree. (Note: this does NOT apply recursively) Thanks On Sat, Mar 17, 2012 at 9:31 AM, rahul sharma rahul23111...@gmail.comwrote: plz explain...i m nt able to get the concept. On Sat, Mar

Re: [algogeeks] Vertical Sum in a given Binary Tree

2012-03-17 Thread rahul sharma
@anna..plz elaborate more... On Sun, Mar 18, 2012 at 12:26 AM, Supraja Jayakumar suprajasank...@gmail.com wrote: Hi I think its the sum of all the right children of the left subtree and left children of the right subtree. (Note: this does NOT apply recursively) Thanks On Sat, Mar 17,