Follow

Translate

Thursday, April 7, 2016

Evaluation of Postfix Expression

Evaluation of Postfix Expression : 

Algorithm : 

1. Add a right parenthesis ")" at the end of P.   [This acts as a sentinel]

2. Scan P from left to right and repeat Steps 3 and 4 for each element of P until the sentinel ")" is encountered.

3. If an operand is encountered, put it on STACK.

4. If an operator  is encountered, then :

(a) Remove the two top elements of STACK, where A is the top element and B is the next-to-top element..

(b) Evaluate B A

(c) Place the result of (b) back on STACK.

[End of If structure.]
[End of Step 2 loop.]

5. Set VALUE equal to the top element on STACK.

6.Exit.
If You want to learn about the technology, computer science & engineering, web programming, freelancing, earning please click here :CSE SOLVE

0 comments:

Post a Comment