To evaluate an expression without any embedded function calls :
2002
To evaluate an expression without any embedded function calls :
- A.
As many stacks as the height of the expression tree are needed
- B.
One stack is enough
- C.
Two stacks are needed
- D.
A Turing machine is needed in the general case
Attempted by 105 students.
Show answer & explanation
Correct answer: B
Without embedded function calls, expression evaluation does not need activation records for nested calls. A single stack can store operands and intermediate results while the expression is evaluated, for example in postfix evaluation. Hence one stack is enough.