Questions: Stack Applications: Expression Evaluation and Parsing

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

You evaluate the postfix expression '4 2 3 + *' using a stack. What is the result?

A11 — treating the expression as infix: 4 * 2 + 3
B10 — treating it as 4 + 2 * 3
C20 — correctly pushing 4, then computing 2+3=5, then 4*5
D24 — multiplying all three numbers
Question 2 Multiple Choice

In Dijkstra's shunting-yard algorithm, when you encounter an operator with lower precedence than the operator currently at the top of the stack, you:

APush the new operator immediately — precedence is handled at evaluation time
BPop and output the higher-precedence operator first, then push the new operator
CDiscard the lower-precedence operator since higher-precedence operators take over
DPush both and use a tiebreaker rule later
Question 3 True / False

Postfix notation is harder for computers to evaluate than infix notation because it requires more stack operations.

TTrue
FFalse
Question 4 True / False

A stack is the appropriate data structure for parenthesis matching because the most recently opened delimiter must be the first to close.

TTrue
FFalse
Question 5 Short Answer

Why is a stack — specifically its LIFO property — the natural data structure for evaluating postfix expressions?

Think about your answer, then reveal below.