user1673198
user1673198

Reputation: 33

see about this infix to postfix conversion

If we solve an infix expression in to postfix expression with braces and without braces will both of them produce same result?

Example:

  1. ((2+8)x9)-(5x(5+2))
  2. 2+8*9-5*5+2

Will both of these examples produce the same results? If No, then why not?

Upvotes: 2

Views: 167

Answers (1)

nhahtdh
nhahtdh

Reputation: 56829

In general, it will not produce the same result, due to the precedence of the operations. For example, if you define * to have higher precedence than + and -, then * must be evaluated before + or -, which changes how the expression is calculated, and also changes the post-fix representation.

Upvotes: 2

Related Questions