Recursion
BinaryTreeNode findMax(BinaryTreeNode root){
if(root == null){
return null;
}
else{
if(root.getRight() == null){
return root;
}
else{
return findMax(root.getRight());
}
}
}
Non-recursive
BinaryTreeNode findMax(BinaryTreeNode root){
if(root == null){
return null;
}
while(root.getRight() != null){
root = root.getRight();
}
return root;
}