# Stacks (evaluating postfix expression)

• October 6th, 2012, 08:59 PM
dx8292
Stacks (evaluating postfix expression)
I'm a little confused so if someone can confirm if I am doing that would be great.

Evaluate postfix expression:

1 2 + 4 * 5 6 * 10 / 8 * +

Me evaluating:

1) 1
2) 2 1
3) 3
4) 4 3
5) 12
6) 5 12
7) 6 5 12
8) 30 12
9) 10 30 12
10) Here's where I get confused. Do I do 30/10 or 10/30 (and is it the same way for subtraction)...3 12
11) 8 3 12
12) 24 12
13) 36
• October 6th, 2012, 09:44 PM
helloworld922
Re: Stacks (evaluating postfix expression)
From Wikipedia:

Operations which are non-commutative are still written in "conventional order", i.e.:

a b op = a op b

4 2 / = 4 / 2 = 2
2 4 / = 2 / 4 = 0.5
• October 6th, 2012, 09:53 PM
dx8292
Re: Stacks (evaluating postfix expression)
Quote:

Originally Posted by helloworld922
From Wikipedia:

Operations which are non-commutative are still written in "conventional order", i.e.:

a b op = a op b

4 2 / = 4 / 2 = 2
2 4 / = 2 / 4 = 0.5

So I guess 36 is right, thanks