Friday, February 6, 2015

week 5 RPN calculator

This week we had a test. But before the test I get to do some additional exercise from lab, it was about RPN calculator. And I found out that this week's lab was also about stack ADT.
These types of ADT such as stack and queue sometimes are handy in dealing with real situations. So about RPN calculator algorithm, basically we deal with a list of symbols that has been well placed(or we need to put them in some order ourselves.) such that we construct a stack instance to operate this list in certain rule, in this case we do a binary operation whenever we encountered an operator, and we pop out the last two items, push in the result after the operation.
This type of calculation may seem not too intuitive to human but it is actually a great way of thinking about how computer works(kind of like when we deal with recursion, the functions we call were stored in a stack.) And this is a simple version of RPN calculator that can explain an idea how it works with the help of stack.

No comments:

Post a Comment