Results 1 to 3 of 3
- 01-29-2012, 08:50 PM #1
Member
- Join Date
- Jan 2011
- Posts
- 7
- Rep Power
- 0
Binary 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.Last edited by joshhazel; 01-30-2012 at 03:00 PM.
- 01-29-2012, 09:38 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
Re: 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:
kind regards,Java Code:class Parameter { Node node; int size; }
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 01-30-2012, 02:08 AM #3
Member
- Join Date
- Jan 2011
- Posts
- 7
- Rep Power
- 0
Similar Threads
-
binary tree
By Dedo in forum Advanced JavaReplies: 15Last Post: 05-26-2011, 09:11 PM -
Help with Binary recursive method to find the largest integer
By flyingcurry in forum New To JavaReplies: 12Last Post: 10-31-2010, 06:14 PM -
binary tree
By ryamz in forum New To JavaReplies: 2Last Post: 08-12-2010, 02:45 AM -
Data Structures(Binary Search Tree to AVL Tree)ASAP pls
By jfAdik in forum Forum LobbyReplies: 0Last Post: 04-04-2010, 07:40 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks