int maxw(node root)
{
if(root == null) return (0);
int L = maxw(root.lchild);
int R = maxw(root.rchild);
return max( (max(R,L,R+L)+root.value), R, L, root.value );
}
-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Debajit Adhikary
Sent: Tuesday, January 29, 2008 12:40 PM
To: Algorithm Geeks
Subject: [algogeeks] Re: Finding the subtree with the largest weight
> On Jan 29, 2008 3:07 PM, Debajit Adhikary <[EMAIL PROTECTED]> wrote:
>
> > Lets say I have a weighted tree (with positive, zero and negative
> > weights for each node).
> > How could I best find the subtree having the maximum weight?
On Jan 29, 3:55 am, "Yingjie Xu" <[EMAIL PROTECTED]> wrote:
> A rooted tree or a general tree?
It is a rooted weighted tree, where each node is assigned a weight
which can be positive, zero or negative.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---