Prefix to Infix Conversion Multiple Choice Questions and Answers (MCQs)

This set of Data Structures & Algorithms Multiple Choice Questions & Answers (MCQs) focuses on “Prefix to Infix Conversion”.

1. What would be the solution to the given prefix notation?

- + 5 / 10 5 5

a) 2
b) 5
c) 10
d) 7
View Answer

Answer: a
Explanation: The infix notation of the given prefix notation is 5+10/5-5 which gives us 2 as our answer.
advertisement
advertisement

2. What would be the solution to the given prefix notation?

/ / / 16 4 2 1

a) 1
b) 4
c) 2
d) 8
View Answer

Answer: c
Explanation: The infix notation to the given prefix notation is 16/4/2/1 which gives us 2 as our answer. The infix notation is got from the prefix notation by traversing the equation from the right.
= 16/4/2/1
= 4/2/1 (16/4=4)
= 2/1 (4/2=2)
= 2 (2/1=2).

3. What would be the solution to the given prefix notation?

advertisement
+ 9 * 3 / 8 4

a) 14
b) 15
c) 18
d) 12
View Answer

Answer: b
Explanation: The infix notation for the given prefix notation is (9+(3*(8/4))) which solves to 15. So 15 is correct answer.
advertisement

4. What would be the solution to the given prefix notation?

- + 1 2 * 3 / 6 2

a) 6
b) -6
c) 3
d) -3
View Answer

Answer: b
Explanation: The infix notation for the given prefix notation is (1+2)-3*(6/2). The result of the given equation is -6.

5. What would be the solution to the given prefix notation?

- * 1 5 / * / 6 3 6 2

a) 1
b) 0
c) -1
d) -2
View Answer

Answer: c
Explanation: The infix notation for the given prefix notation is (1*5)-(6/3)*6/2. The result of the equation is -1.

6. What would be the solution to the given prefix notation?

* / + 1 2 / 4 2 + 3 5

a) 12
b) 7.5
c) 9
d) 13.5
View Answer

Answer: a
Explanation: The infix notation of the given prefix notation is ((1+2)/(4/2))*(3+5) which solves to (3/2)*8 which by solving gives us 12.

7. Given a prefix and a postfix notation what are the difference between them?
a) The postfix equation is solved starting from the left whereas the prefix notation is solved from the right
b) The postfix equation is solved starting from the right whereas the prefix notation is solved from the left
c) Both equations are solved starting from the same side(right)
d) Both equations are solved starting from the same side(left)
View Answer

Answer: a
Explanation: The postfix notation is solved starting from left but whereas the prefix notation is reversed after creating them, therefore it’s solved starting from right.

8. When converting the prefix notation into an infix notation, the first step to be followed is ________
a) Reverse the equation
b) Push the equation to the stack
c) Push the equation onto the queue
d) Push the equation to the stack or queue
View Answer

Answer: a
Explanation: The steps that are followed are: the equation is reversed, pushed onto a stack, popped one by one and solved. Therefore the first step is reversing the equation.

9. The time complexity of converting a prefix notation to infix notation is _________
a) O(n) where n is the length of the equation
b) O(n) where n is number of operands
c) O(1)
d) O(logn) where n is length of the equation
View Answer

Answer: a
Explanation: The processes that are involved are reversing the equation (O(n)), pushing them all onto the stack(O(n)), and popping them one by one and solving them (O(n)). Hence the answer is O(n) where n is the length of the equation.

10. Given two processes (conversion of postfix equation to infix notation and conversion of prefix notation to infix notation), which of the following is easier to implement?
a) Both are easy to implement
b) Conversion of postfix equation to infix equation is harder than converting a prefix notation to infix notation
c) Conversion of postfix equation to infix equation is easier than converting a prefix notation to infix notation
d) Insufficient data
View Answer

Answer: c
Explanation: As the conversion of prefix notation to infix notation involves reversing the equation, the latter is harder to implement than postfix to infix process.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.