fix BinaryTree.java put method#644

This commit is contained in:
1700022814 2018-11-18 16:22:08 +08:00
parent 819b7fd3da
commit c4f7a45ed2

View File

@ -69,8 +69,12 @@ class Tree{
Node current = root;
while (current != null) {
if(key < current.data) {
if(current.left == null)
return current; //The key isn't exist, returns the parent
current = current.left;
} else if(key > current.data) {
if(current.right == null)
return current;
current = current.right;
} else { // If you find the value return it
return current;