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.
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.
Node 90
2.
Node 85
3.
Node 40
4.
Node 70
5.
Node 50
6.
Node 35
7.
Node 30
8.
Node 20
Unlock full course notes by signing up
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 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.
Queue length, recursion depth and visit positions in traversals of one tree
A binary tree with nine nodes has root A. Each line gives a node's left child and then its right child; nodes not listed as parents are leaves.