Created
May 16, 2017 19:31
-
-
Save lironsade/b80bcb1a51950ffbe8a4eda3d209bbce to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int contains(int searchVal) { | |
Node pointer = this.getRoot(); | |
int depth = 0; | |
while(pointer != null) { | |
if(pointer.getData() == searchVal) { | |
return depth; | |
} | |
if (pointer.getData() > searchVal) { | |
pointer = pointer.getLeft(); | |
} else{ | |
pointer = pointer.getRight(); | |
} | |
depth++; | |
} | |
return NOT_FOUND; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment