[ HOME ] [ UP ] [ TM ] [ RAM ] [ Sequence ] [ Skip List ] [ Search ] [ Josephus ] [ SOE ] [ PCP ] [ Hanoi ] [ Queens ] [ Maze ] [ RPN ] [ Pattern ] [ Huffman ] [ BST ] [ AVL ] [ Splay ] [ Red-Black ] [ B-Tree ] [ Trie ] [ Quadtree ] [ Heap ] [ PQ ] [ Hashing ] [ Sorting ] [ Insertionsort ] [ Mergesort ] [ Shellsort ] [ Heapsort ] [ Tournamentsort ] [ Quicksort ] [ Binsort ] [ Radixsort ] [ Graph Traversal ] [ Critical Path ] [ Shortest Path ] [ MST ] [ Maxflow ] [ DynaProg ] [ DSN ] [ TSP ]


Reverse Polish Notation


Reverse Polish Notation@Oregonstate

An algebraic expression in Reverse Polish Notation is evaluated as follows.

  • The expression is scanned from left to right.
  • If a number is encountered, it is pushed onto the stack.
  • If an operator is encountered, it is applied to the top two operands on the stack. After removing the operands used, the result is pushed onto the stack.
  • When you provide an expression to be evaluated, separate numbers and operators with spaces as 10 20 + 2 * 30 4 6 + + *.

(Courtesy of http://web.engr.oregonstate.edu/~minoura/cs261/)


Expression Tree@Oregonstate

An algebraic expression is represented as a tree and is evaluated.

  • Each leaf node represents an operand.
  • An internal node is an operator.
  • A post-order traversal is performed over the nodes.
  • In a post-order traversal, each node is visited after its descendant nodes are visited.

(Courtesy of http://web.engr.oregonstate.edu/~minoura/cs261/)



TOP

[ HOME ] [ UP ] [ TM ] [ RAM ] [ Sequence ] [ Skip List ] [ Search ] [ Josephus ] [ SOE ] [ PCP ] [ Hanoi ] [ Queens ] [ Maze ] [ RPN ] [ Pattern ] [ Huffman ] [ BST ] [ AVL ] [ Splay ] [ Red-Black ] [ B-Tree ] [ Trie ] [ Quadtree ] [ Heap ] [ PQ ] [ Hashing ] [ Sorting ] [ Insertionsort ] [ Mergesort ] [ Shellsort ] [ Heapsort ] [ Tournamentsort ] [ Quicksort ] [ Binsort ] [ Radixsort ] [ Graph Traversal ] [ Critical Path ] [ Shortest Path ] [ MST ] [ Maxflow ] [ DynaProg ] [ DSN ] [ TSP ]

Copyleft (c) 2003-3002, Junhui Deng
Last updated on 05.30.2012