I have a binary tree and want to traverse through it to find the sub tree that has the largest total value.

I get the concept of this issue but cannot quite figure out how i will program it. Any help appreciated.

Printable View

- 01-29-2012, 08:50 PMjoshhazelBinary Tree Help - Find the largest sub-tree
I have a binary tree and want to traverse through it to find the sub tree that has the largest total value.

I get the concept of this issue but cannot quite figure out how i will program it. Any help appreciated. - 01-29-2012, 09:38 PMJosAHRe: Binary Tree Help - Find the largest sub-tree
If you can build a method that calculates the 'size' of a tree, you can always add one parameter that can contain a Node and the size of the tree starting at that Node. The recursion is just needed for the calculation of the 'size'; the parameter is just passed around and contains the Node and its 'size'. the parameter has the type:

Code:`class Parameter {`

Node node;

int size;

}

Jos - 01-30-2012, 02:08 AMjoshhazelRe: Binary Tree Help - Find the largest sub-tree
I need to be able to do this recursively without storing a sub-tree value.