+1 vote
in Data Structures & Algorithms I by (110k points)
While evaluating a postfix expression, when an operator is encountered, what is the correct operation to be performed?

(a) push it directly on to the stack

(b) pop 2 operands, evaluate them and push the result on to the stack

(c) pop the entire stack

(d) ignore the operator

This question is from Application of Stacks topic in section Application of Stacks of Data Structures & Algorithms I

I had been asked this question in homework.

1 Answer

+1 vote
by (408k points)
selected by
 
Best answer
Right choice is (b) pop 2 operands, evaluate them and push the result on to the stack

The explanation is: When an operator is encountered, the first two operands are popped from the stack, they are evaluated and the result is pushed into the stack.

Related questions

Welcome to TalkJarvis QnA, a question-answer community website for the people by the people. On TalkJarvis QnA you can ask your doubts, curiosity, questions and whatever going in your mind either related to studies or others. Experts and people from different fields will answer.

Categories

...