GATE / CS ARCHIVE

GATE CSE 2000 / QUESTION 1.14

Well-formed nested binary-tree notation

Data Structures · Tree Properties & Traversals · Full GATE CSE 2000 paper

GATE 2000, Q1.14 1 mark · MCQ
Report issue

Tree Properties & Traversals

Question 1.14, GATE 2000: A nonleaf is written (root left right), with leaves represented by labels and empty subtrees by NULL. Choose a valid expression: A (1 2 (4 5 6 7)); B (1 ((2 3 4) 5 6) 7); C (1 (2 3 4) (5 6 7)); D (1 (2 3 NULL) (4 5)).
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Step 1: Every parenthesized node must begin with a node label and have exactly two child descriptions. C has root 1, left subtree rooted 2 with leaves 3,4, and right subtree rooted 5 with leaves 6,7.

Step 2: A gives node 4 three children. B uses a whole subtree where a root label should be. D gives node 4 only one child without an explicit second subtree.

Only C consistently follows the notation.

Original paper, page 2