Binary tree 2 Flashcards

1
Q

What is Depth-first pre-order.

A

Visit the root then the sub-trees.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is Depth-first post-order.

A

Visit the sub-trees and then the root.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly