In the postfix expression evaluation example, the two most re- cent operands are popped when an operator is encountered so that the sub-expression can be evaluated. The first operand popped is treated as the second operand in the sub-expression, and the second operand popped is the first. Give and explain an example that demonstrates the importance of this aspect of the solution.

What will be an ideal response?

For operations such as addition and multiplication, the order of operands does not matter, but for subtraction and division, for instance they do. So the postfix expression
17 4 -
means to subtract 4 from 17 (and not the other way around). When these operands are pushed onto the stack, 17 goes on first, then 4 on top. So when they are popped to be evaluated, the first value popped must be treated as the second operand.

Computer Science & Information Technology

You might also like to view...

Each business process contributes to the operation of the enterprise, but there are some without which the enterprise cannot carry out the others. What are these called?

A) Risk assessment processes B) Disaster recovery processes C) Mission-critical processes D) Risk management processes

Computer Science & Information Technology

Which of the following statements about asymmetric key cryptography is true?

A) Asymmetric key cryptography uses one shared key. B) Asymmetric key cryptography is also called private key cryptography. C) Asymmetric key cryptography uses two keys called public keys. D) Asymmetric key cryptography is also called public key cryptography.

Computer Science & Information Technology