Reputation: 33
If we solve an infix expression in to postfix expression with braces and without braces will both of them produce same result?
Example:
Will both of these examples produce the same results? If No, then why not?
Upvotes: 2
Views: 167
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