Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Path
- {
- Node * root; // the highest vertex in this path
- int score;
- Path(Node * n = NULL, int s = 0)
- : root(n), score(s) {}
- };
- struct Return
- {
- Path arm; // a path that is left or right arm of future best path
- Path best; // complete subtree with the best score down below current node
- };
- Return maxSum(Node * n)
- {
- if(!n) { return Return(); }
- Return L = maxSum(n->left);
- Return R = maxSum(n->right);
- }
Advertisement
Add Comment
Please, Sign In to add comment