LOGBOOK

HELP

Quiz Entry - updated: 2026.09.29

In the tree where A has children B and C, B has children D and E, and C has only a right child F, what are the preorder, inorder, postorder and breadth-first sequences?

Preorder A B D E C F · inorder D B E A C F · postorder D E B F C A · breadth-first A B C D E F.

The example tree: A with children B and C, B with D and E, C with a right child F

* C has only a right child, so F comes after C in inorder. *

The four visiting orders of the example tree side by side

* Same tree, four orders; the leaves D, E, F keep their relative order in the first three. *

Work each one out from its rule:

  • Preorder (node, left, right): A, then B's subtree (B, D, E), then C's subtree (C, F).
  • Inorder (left, node, right): B's subtree gives D, B, E; then A; then C's subtree. C has no left child, so C comes first and then F.
  • Postorder (left, right, node): D, E, then B; F, then C; A last.
  • Breadth-first (by level): A; B, C; D, E, F.

Quick checks that catch most mistakes: preorder always starts with the root, postorder always ends with it, and in inorder the root sits exactly between its left and right subtree's nodes.

Tip: a hand trick for the three depth-first orders is to trace a line around the tree counter-clockwise, starting left of the root. Preorder lists a node when the line passes its left side, inorder when it passes underneath, postorder when it passes its right side.

Go deeper:

From Quiz: ADS / Trees: Structure, Storage and Traversals | Updated: Sep 29, 2026