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?

Category: QuestionsAssume 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?
Editor">Editor Staff asked 2 months ago

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
 
Please solve with an explanation.

1 Answers
Editor">Editor Staff answered 2 months ago

Correct option is (b) abc X+ de^f^ –
 
Easy 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 ^ -).