Created
December 15, 2013 21:50
-
-
Save zonski/7978668 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 class BinaryTree { | |
public boolean search(int value) { | |
return search(value, this.root); | |
} | |
private boolean search(int value, Node root) { | |
if (root.getValue() == value) { | |
return true; | |
} | |
if (value < root.getValue() && !root.isLeftEmpty()) { | |
return search(value, root.getLeft()); | |
} | |
if (value > root.getValue() && !root.isRightEmpty()) { | |
return search(value, root.getRight()); | |
} | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment