GateAI
Trees

GATE CSE 2016 Set 2 · Q36

MCQ2 marksMedium

Time

Consider the following New-order\text{New-order} strategy for traversing a binary tree: • Visit the root;• Visit the right subtree using New-order\text{New-order}; • Visit the left subtree using New-order\text{New-order}; The New-order\text{New-order} traversal of the expression tree corresponding to the reverse polish expression 3 4 * 5 - 2 ^ 6 7 * 1 + - is given by:

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: C) - + 1 * 7 6 2 - 5 * 4 3

Trees

To find the New-order\text{New-order} traversal, first construct the binary expression tree from the reverse Polish (postfix) expression: 3 4 * 5 - 2 ^ 6 7 * 1 + -.

  1. 3, 4, *  ⟹  (∗ with left 3, right 4)\implies (* \text{ with left } 3, \text{ right } 4)

  2. 5, -  ⟹  (− with left (∗ 3 4), right 5)\implies (- \text{ with left } (* \ 3 \ 4), \text{ right } 5)

  3. 2, ^  ⟹  ( with left (−…5), right 2)\implies (^ \text{ with left } (- \dots 5), \text{ right } 2)

  4. 6, 7, *  ⟹  (∗ with left 6, right 7)\implies (* \text{ with left } 6, \text{ right } 7)

  5. 1, +  ⟹  (+ with left (∗ 6 7), right 1)\implies (+ \text{ with left } (* \ 6 \ 7), \text{ right } 1)

  6. -   ⟹  (− with left (…2), right (+…1))\implies (- \text{ with left } (^ \dots 2), \text{ right } (+ \dots 1))

The root of the expression tree is -.

  • Left subtree:( with left (− (∗ 3 4) 5) and right 2)(^ \text{ with left } (- \ (* \ 3 \ 4) \ 5) \text{ and right } 2)

  • Right subtree:(+ with left (∗ 6 7) and right 1)(+ \text{ with left } (* \ 6 \ 7) \text{ and right } 1)

Now, perform the New-order\text{New-order} traversal (Root →\to Right →\to Left):

  • Visit Root: -

  • Visit Right Subtree (+ (* 6 7) 1):

    • Root: +

    • Right: 1

    • Left: (* 6 7)   ⟹  \implies Root: *, Right: 7, Left: 6  ⟹  ∗ 7 6\implies * \ 7 \ 6

    • Result for right subtree: + 1 * 7 6

  • Visit Left Subtree (^ (- (* 3 4) 5) 2):

    • Root: ^

    • Right: 2

    • Left: (- (* 3 4) 5)   ⟹  \implies Root: -, Right: 5, Left: (* 3 4)   ⟹  \implies Root: *, Right: 4, Left: 3  ⟹  ∗ 4 3\implies * \ 4 \ 3

    • Result for left subtree: ^ 2 - 5 * 4 3

Concatenating these gives:

− + 1 ∗ 7 6 ^ 2 − 5 ∗ 4 3- \ + \ 1 \ * \ 7 \ 6 \ \hat{} \ 2 \ - \ 5 \ * \ 4 \ 3

This matches option C.

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Trees previous year question is Q36 of the GATE CSE 2016 Set 2 paper. Find more GATE CSE PYQs on Trees in Programming and Data Structures, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Trees PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Trees in GATE CSE

Trees has 13 GATE CSE PYQs across 11 papers from 2012 to 2026. 3 of them are 2-mark MCQs like this one, and GATE CSE 2016 Set 2 has 2.

How GATE tests Trees

More from GATE CSE 2016 Set 2

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2016 Set 2 · Q36 · MCQ

Consider the following New-order strategy for traversing a binary tree: • Visit the root; • Visit the right subtree using New-order; • Visit the left subtree using New-order; The New-order traversal of the expression tree corresponding to the reverse polish expression 3 4 * 5 - 2 6 7 * 1 + - is given by:

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.