“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.