private int maxResult = 0;
public int findMaxRoot(Node root)
{
int result = root.getValue();
List
if (nodes.size() == 0)
{
return result;
}
else
{
int maxChildTreeValue = 0;
for (int i=0; i
//result = root.getValue();
Node oneNode = nodes.get(i);
result = findMaxRoot(oneNode);
if (result > maxChildTreeValue)
maxChildTreeValue = result;
}
result = maxChildTreeValue + root.getValue();
if (result > maxResult)
{
maxResult = result;
}
//maxResult = maxResult + root.getValue();
}
return maxResult;
}
No comments:
Post a Comment