A binary tree has its root at the node holding 50. Each line below gives a node's left child and then its right child; nodes not listed as parents are leaves.

  • 50: left child 30, right child 70
  • 30: left child 20, right child 40
  • 70: no left child, right child 85
  • 40: left child 35, no right child
  • 85: no left child, right child 90

Arrange the nodes in the order a breadth-first (level-order) traversal visits them. The traversal starts at the root, uses a first-in, first-out queue, and enqueues each node's left child before its right child.

  1. 1.

    Node 90

  2. 2.

    Node 85

  3. 3.

    Node 40

  4. 4.

    Node 70

  5. 5.

    Node 50

  6. 6.

    Node 35

  7. 7.

    Node 30

  8. 8.

    Node 20

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

The binary tree in the figure has six nodes, each labelled with a letter. Complete the table by entering the letter of the node visited at each position in a pre-order, an in-order and a post-order depth-first traversal. In every traversal, visit a node's left subtree before its right subtree.


A binary tree with root M; M has left child E and right child T; E has left child B and right child H; T has no left child and a right child W.


Traversal1st2nd3rd4th5th6th
Pre-order
In-order
Post-order

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

A binary tree has eight nodes, each labelled with a distinct letter. Its pre-order traversal is K, F, B, T, H, R, D, M and its in-order traversal is B, F, H, T, K, R, M, D. Reconstruct the tree and give its post-order traversal. Type the eight letters in post-order with no spaces or commas, in the same style as ABCDEFGH.

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors