Stacks and arithmetic expressions
Hello,
I recently came upon a problem. In the Uni I am in, we received an assignment to write a function that can evaluate an arithmetic expression. First thought: Binary Tree, but the first detail of the assignment: Trees are not allowed. So the hint was to use a stack..
We never learned anything about stacks or queues or any sort of that, so Im kind of feeling helpless. I searched google/yahoo and came upon only one 'good' article which was in wikipedia. http://en.wikipedia.org/wiki/Stack_%28data_structure%29
So I am asking here for any help people might offer. What are stacks really? How do the push, pop functions work? DO I have to convert the arithmetic expression into Postfix form first? (The symbols allowed are +-/*% and parantheses, so thank god no variables or that sort, but the numbers can be infinitely long). Are stacks really the only way to solve this? [excluding binary trees]
Any help would be greatly appreciated!