We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 819b7fd commit c4f7a45Copy full SHA for c4f7a45
DataStructures/Trees/BinaryTree.java
@@ -69,8 +69,12 @@ public Node find(int key) {
69
Node current = root;
70
while (current != null) {
71
if(key < current.data) {
72
+ if(current.left == null)
73
+ return current; //The key isn't exist, returns the parent
74
current = current.left;
75
} else if(key > current.data) {
76
+ if(current.right == null)
77
+ return current;
78
current = current.right;
79
} else { // If you find the value return it
80
return current;
0 commit comments