MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

THEORY OF COMPUTATION

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
What is the postfix equivalent for the following infix expression?(2/4)*(5-6)
A
2 4 5 6 /-*
B
2 4 / 5 6-*
C
2 4 / * 5-6
D
2 4 / 5-6 *
Explanation: 

Detailed explanation-1: -Hence, value = (2 + 3) * (4 – (5 – 6)) = 5 *(4 – (-1)) = 5*5 = 25. Explanation: To convert from postfix to prefix, we first convert it to infix and then to prefix.

Detailed explanation-2: -hHow do we convert it to postfix notation. For example, the infix expression (2+3)*(4+5) in postfix notation is 23+45+* and the infix expression 2+3*4+5 in postfix notation is 234*+5+. Also, since our four operators are left associative, 2 + 3 + 4 translates to 23+4+ and not 234++.

Detailed explanation-3: -1. The result of evaluating the postfix expression 5, 4, 6, +, *, 4, 9, 3, /, +, * is? = 350. 2.

Detailed explanation-4: -Explanation: Using the infix to postfix expression conversion algorithm, the corresponding postfix expression is found to be abc*+de*+.

There is 1 question to complete.