Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Set;
- import java.util.TreeSet;
- public class Main {
- public static void main(String[] args) {
- class BTree {
- int value = 0 ;
- BTree left, right;
- public boolean contains (int v) {
- if (value == v) {
- return true;
- }
- if (left != null && v < value) {
- return left.contains(v);
- }
- else if (right != null && v > value) {
- return right.contains(v);
- }
- return false;
- }
- }
- BTree tree = new BTree();
- tree.contains(100);
- }
- }
Add Comment
Please, Sign In to add comment