Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
+1 vote
140 views
in Information Technology by (85.4k points)
closed by

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:


1. + – 1 6 7 * 2 ^ 5 – 3 4 *
2. – + 1 * 6 7 ^ 2 – 5 * 3 4
3. – + 1 * 7 6 ^ 2 – 5 * 4 3
4. 1 7 6 * + 2 5 4 3 * – ^ –

1 Answer

0 votes
by (88.5k points)
selected by
 
Best answer
Correct Answer - Option 3 : – + 1 * 7 6 ^ 2 – 5 * 4 3

In case of reverse polish notation, we follow the:

1) visit left subtree

2) visit right subtree

3) visit root

New order strategy is given as:

1) visit root

2) visit right subtree

3) visit left subtree

It is the reverse of reverse- polish notation.

So, for finding the new order traversal of given reverse polish notation just reverse that:

Reverse polish traversal: 3 4 * 5 – 2 ^ 6 7 * 1 + -

New order traversal:  – + 1 * 7 6 ^ 2 – 5 * 4 3

Alternate solution:

Convert the given reverse polish notation in IN- order

3 4 * 5 – 2 ^ 6 7 * 1 + -

(3 * 4) 5 – 2 ^ 6 7 * 1 + -

((3*4) - 5) 2 ^ 6 7 * 1 + -

(((3*4) - 5)^ 2) 6 7 * 1 + -

(((3*4) - 5)^ 2) (6 * 7) 1 + -

(((3*4) - 5)^ 2) ((6 * 7) + 1)

(((3*4) - 5)^ 2) - ((6 * 7) + 1)

Now, from this inorder traversal, find the new order traversal;

(((3*4) - 5)^ 2) - ((6 * 7) + 1)

- ((6 * 7) + 1) (((3*4) - 5)^ 2)

- + 1 (6 * 7) (((3*4) - 5)^ 2)

- + 1 * 7 6 (((3*4) - 5)^ 2)

- + 1 * 7 6 ^ 2 ((3*4) - 5)

- + 1 * 7 6 ^ 2 - 5 (3*4)

- + 1 * 7 6 ^ 2 - 5 * 4 3

Hence option 3 is correct.

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...