Skip to content

Latest commit

 

History

History

find-max-tree-node

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

You are given a binary tree. Implement the method findMax which returns the maximal node value in the tree.

For example, maximum in the following Tree is 11.

              7
            /   \ 
           /     \
          5       2
           \       \
           6        11          
           /\      /
          1  9   4

Note:

  • Tree node values range is Integer MIN VALUE - Integer MAX VALUE constants.
  • Tree can unbalanced and unsorted.
  • Root node is always not null.

You are given a tree node class as follows:

class TreeNode {
  TreeNode  left;
  TreeNode  right;
  int value;
}