Skip to content

Instantly share code, notes, and snippets.

@zonski
Last active December 31, 2015 11:19
Show Gist options
  • Save zonski/7978720 to your computer and use it in GitHub Desktop.
Save zonski/7978720 to your computer and use it in GitHub Desktop.
public class BinaryTree {
private Node root;
public boolean search(int value) {
return root != null && root.search(value);
}
}
public class Node {
private int value;
public boolean search(int value) {
if (this.value == value) {
return true;
} else if (value > this.value) {
return right != null && right.search(value);
} else {
return left != null && left.search(value);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment