We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 6218de0 + c4f7a45 commit 217b85fCopy full SHA for 217b85f
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