Last active
December 31, 2015 11:19
-
-
Save zonski/7978720 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 { | |
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