Guest User

Untitled

a guest
Mar 20th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. import java.util.Set;
  2. import java.util.TreeSet;
  3.  
  4. public class Main {
  5.  
  6. public static void main(String[] args) {
  7.  
  8. class BTree {
  9. int value = 0 ;
  10. BTree left, right;
  11.  
  12.  
  13. public boolean contains (int v) {
  14. if (value == v) {
  15. return true;
  16. }
  17.  
  18. if (left != null && v < value) {
  19. return left.contains(v);
  20. }
  21. else if (right != null && v > value) {
  22. return right.contains(v);
  23. }
  24. return false;
  25. }
  26. }
  27. BTree tree = new BTree();
  28. tree.contains(100);
  29.  
  30. }
  31. }
Add Comment
Please, Sign In to add comment