“Create a binary tree with A as root, B and C as its left and right children, D and E under B, H under D, and F and G under C, for practising tree traversals.”
図の背後にある意思決定を読み解く。
Give the root two children and each child two leaves.
Make traversal order easy to read.
Use the same tree for preorder, inorder and postorder.
Use this small tree for introductory traversal exercises.
よくある質問
What is preorder traversal?
Visit the root, then the left subtree, then the right subtree.
What is inorder traversal?
Visit the left subtree, then the root, then the right subtree.
What is postorder traversal?
Visit the left subtree, then the right subtree, then the root.