Preorder
- Preorder is what we often sayLeft - root - Right
- This binary sort tree traversal may be sequentially output each subnode
public void printTree(){
if(isEmpty())
System.out.println("Empty tree");
else
printTree(root);
}
public void printTree(BinaryNode<T> t){
printTree(t.left);
System.out.println(t.element);
printTree(t.right);
}
Postorder
- Postorder is what we often sayLeft - Right - root
- It is used generically herein using the calculated height of the book.
public int height(BinaryNode<T> t){
if(t == null)
return -1;
else
return Math.max(height(t.left),height(t.right))+1;
}
}
Preorder
- Postorder is what we often say that the root == - left - right ==
- The current node process before the child node.