Implement a Node class and a Binary Tree class. Extend the Binary Tree class with a Binary Search Tree class.
For traversal in Binary Trees has the time complexity of O(N) because we need to touch each node. This is the same for breadth first with a queue and depth first with recursion.
The space complexity when traversing Binary Trees using recursion is O(N) due to the stack frames increasing for each edge in the height of the tree. The space complexity for breadth with a queue is porportional to the width of the widest point in the tree, since that is the amount of nodes that will be in the queue at one time.
public T[] preOrderTraversal() Returns an array in pre-order.
public T[] inOrderTraversal() Returns an array in-order.
public T[] postOrderTraversal() Returns an array in post-order.
public T[] breadthFirstTraversal() Returns an array in breadth first order.
public void add(T value) Adds a node with value to the correct position in the tree.
public boolean contains(T value) Returns true if the tree contains the specified value.