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
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,
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
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
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
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.
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
@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
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
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
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
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;
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
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
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)
/ \ /
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 ,
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
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
@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,
19 matches
Mail list logo