ChatDiagram
computer science · data structures

Binary tree traversal example.

This balanced binary tree is a compact example for learning recursive traversal. Each internal node has a left and a right child, and the labels make the visit order easy to record. In preorder, visit the root before its subtrees. In inorder, visit the left subtree, root and right subtree. In postorder, visit both subtrees before the root. A small labelled tree like this helps students check that they understand the difference between the three algorithms before using larger trees.

النوع مخطط هيكليالمعيار Reingold-Tilford tidy treeالمحرّك schematex-orgchartآخر تحديث 24‏/9‏/2026
Binary Tree for Traversal
Drawing preview
الطلب

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

جرّب إذنLabel the inorder traversal D, B, E, A, F, C, G.Add H as the left child of D.
ما الذي يتضمنه هذا الرسم

اقرأ القرارات الكامنة وراءه.

01Balanced shape

Give the root two children and each child two leaves.

02Letter labels

Make traversal order easy to read.

03Traversal practice

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.