MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

DATA STRUCTURES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
(A+B) is example of which of the following notation.
A
infix
B
prefix
C
postfix
D
none of above
Explanation: 

Detailed explanation-1: -In this notation, operator is prefixed to operands, i.e. operator is written ahead of operands. For example, +ab. This is equivalent to its infix notation a + b. Prefix notation is also known as Polish Notation.

Detailed explanation-2: -Infix notation: X + Y Operators are written in-between their operands. The expression: A * ( B + C ) / D translates to “Add B and C together, multiply the result by A, then divide by D to give the final answer."

Detailed explanation-3: -Infix notation is the notation commonly used in arithmetical and logical formulae and statements. It is characterized by the placement of operators between operands-"infixed operators"-such as the plus sign in 2 + 2.

Detailed explanation-4: -Now consider the infix expression (A + B) * C. Recall that in this case, infix requires the parentheses to force the performance of the addition before the multiplication. However, when A + B was written in prefix, the addition operator was simply moved before the operands, + A B.

Detailed explanation-5: -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++.

There is 1 question to complete.