I found it quite confusing. Any clarification would be appreciated.

Share

Talk Programming , Career, Mental Health, Talk Personal Finance ❤️ Post a query and receive responses ✅

Post a query and receive responses. Ask anything, Ask Mitra ❤️

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

In a postfix expression( Reverse Polish notation), the operator is placed after the operands (the values on which the operator operates).

For the expression “a^b^c”, the postfix notation would be “ab^c^”. Here, the “^” operator is placed after the operands “a” and “b”, and then after the result of the first operation (“a^b”) and the operand “c”.

In other words, the postfix notation for the expression “a^b^c” would be:

The order of operations is important in this expression. In infix notation (the standard notation most people are familiar with), the expression “a^b^c” would be interpreted as “a^(b^c)”, which would give a different result.

For example, if “a” is 2, “b” is 3, and “c” is 4, the postfix notation “ab^c^” would give the result 2^(3^4), which is 2^81 = 68719476736. In infix notation, the expression “a^b^c” would be interpreted as “2^(3^4)”, which would give the result 2^81 = 1.

I hope this helps clarify the concept of postfix notation. Let me know if you have any further questions.

Thanks for your answer but I was confused with associativity of ^ operator being from right to left. What about it? Does it have nothing to do with it? Please enlighten me..

Associativity is taken into consideration when there are operators with same precedence (like * and /) . Because of Right to Left associativity, here you would convert the rightmost expression 1st (b^c). You will get different answers based on what associativity you use

I find that adding brackets makes conversion easier.

Left-to-Right:

Right-to-Left:

This answer was edited.THE BIG OCEAN Which programming language are you talking about? I dont know any language which uses ^ as

expontiation.^isBitwise XORand evaluated left to rightPostfix expression for a^b^c will be ab^c^.

As ^(bitwise xor) is evaluated left to right we can write a^b^c as ((a^b)^c). Now as both operand are ^ so they have same precedence. Moving ^ operand to just outside of nearest R.H.S parenthesis we will get answer i.e

ab^c^.Another example for clearence is.

a+b*c-d

= a+(b*c)-d

= (a+(b*c))-d

= ((a+(b*c))-d)

=> ((a+bc*)-d) [

*having greater precedence evaluated first]=> (abc*+-d) [

+,-has same precedence so evaluated Left to Right]=> abc*+d- [this is the answer]