40. Assume that the operators +,-, X are left associative and ^ is right associative. The order of precedence (from highest to lowest) is ^, X, +, -. The postfix expression for the infix expression a + b X c – d ^ e ^ f is?

a) abc X+ def ^^ –
b) abc X+ de^f^ –
c) ab+c Xd – e ^f^
d) -+aXbc^ ^def

Answer: b
Explanation: Given Infix Expression is a + b X c – d ^ e ^ f. (a b c X +) (d ^ e ^ f). ‘–‘ is present in stack. (a b c X + d e ^ f ^ -). Thus the final expression is (a b c X + d e ^ f ^ -)

Leave a Reply

Your email address will not be published.