Binary tree 2 Flashcards
1
Q
What is Depth-first pre-order.
A
Visit the root then the sub-trees.
2
Q
What is Depth-first post-order.
A
Visit the sub-trees and then the root.
3
Q
What is Depth-first in-order.
A
This is usually for Binary Trees where there are two
sub-trees. Visit the left sub-tree, then the root and then the
right sub-tree.
4
Q
Recursive procedure for finding height of tree.
A
public int getHeight(BinaryTree n){ if (n == null){ return 0; } return max(getHeight(n.getLeft()), getHeight(n.getRight()) + 1; }