Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public final class Trees {
- /**
- * Node of a binary search tree
- * Left subtree contains values that are less (or equal) than value of this node
- * Right subtree contains values that are greater than a value of this node
- */
- //FIXME Make this type safe using generics
- public interface Node {
- /**
- * Returns value associated with this node
- */
- Comparable value();
- /**
- * Returns left subtree if present
- */
- Node left();
- /**
- * Returns right subtree if present
- */
- Node right();
- }
- /**
- * Check whether tree contains provided value
- * @return true if value present in the tree
- */
- static boolean contains(Node tree, Comparable a) {
- //FIXME Provide implementation
- return false;
- }
- /**
- * Find a tree node that is Least Common Ancestor (com.example.LCA) for
- * provided values
- *
- * @param searchTree root node of a binary search tree
- * @param a one of thee nodes in a tree
- * @param b one of thee nodes in a tree
- * @return com.example.LCA
- */
- public static Node findLCA(Node searchTree, Node a, Node b) {
- //FIXME Provide implementation
- return null;
- }
- public static Node bfs(Node tree, Node a) {
- //FIXME Provide implementation
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement