The Following is in Reverse Polish Notation (Sometimes called Postfix Notation)
5 6 2 + 6 1 4 2 - 8 + * - / 3 - +
What value does it evaluate to?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
I got 0 for the answer. Python agrees with me as well. The reason why your solution is incorrect is because you are subtracting and dividing the wrong way round in the stacks. Because of their non-commutative properties, you are getting an incorrect answer.
EDIT: Okay, so you fixed your solution. It's alright now. :)
The answer is 0. I have a Python code and as well as a method to do it manually.
Operation 5 6 2 + 6 1 4 2 − 8 + ∗ − / 3 − + Stack 5 6 5 2 6 5 8 5 6 8 5 1 6 8 5 4 1 6 8 5 2 4 1 6 8 5 2 1 6 8 5 8 2 1 6 8 5 1 0 1 6 8 5 1 0 6 8 5 − 4 8 5 − 2 5 3 − 2 5 − 5 5 0
Thus, the answer is 0. My Python code is below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
This outputs an answer of 0.
Problem Loading...
Note Loading...
Set Loading...
Using a stack, and showing all changes -
So the answer is 0