Skip to content

Instantly share code, notes, and snippets.

@zonski
Created December 15, 2013 21:50
Show Gist options
  • Save zonski/7978668 to your computer and use it in GitHub Desktop.
Save zonski/7978668 to your computer and use it in GitHub Desktop.
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