1 / 41
Settings
<<<>>>
Preorder traversals start by processing the root node.
- // Preorder traversal for general trees
- static void preorder(GTNode rt) {
- PrintNode(rt);
- if (!rt.isLeaf()) {
- GTNode temp = rt.leftmostChild();
- while (temp != null) {
- preorder(temp);
- temp = temp.rightSibling();
- }
- }
- }
R
A
B
C
D
E
F
rt