PRASHNIKAप्रश्निका
‹ Back to the paper

Answer the following questions from the diagram of a Binary Tree given below: Write the postorder…

Computer Science20173 marksShort answer
Answer the following questions from the diagram of a Binary Tree given below:
Binary Tree
Binary Tree
(i)[1.0]
Write the postorder traversal of the above tree structure.
(ii)[1.0]
State the level numbers of the nodes N and R if the root is at 0 (zero) level.
(iii)[1.0]
List the internal nodes of the right sub-tree.

Answer

Answer (i)

AI
W F Y N R Z D G M Postorder (left, right, root): left subtree of M is N with W, then Y (with its left child F): W F Y N; right subtree G with Z (right child R), then D: R Z D G; then the root M.

Answer (ii)

AI
Level of N = 1 and level of R = 3. Root M is at level 0; N is a child of M (level 1); R is a child of Z, which is a child of G, a child of M (M 0, G 1, Z 2, R 3).

Answer (iii)

AI
G, Z The right sub-tree has root G with nodes Z, D and R. Internal (non-leaf) nodes are those with at least one child: G and Z. D and R are leaf nodes.
Data structures

From ISC 2017 Computer Science Paper 1, question 12(b).