Stacks
Question 1 |
Which of the following is essential for converting an infix expression to the postfix from efficiently?
An operator stack | |
An operand stack | |
An operand stack and an operator stack | |
A parse tree |
Question 1 Explanation:
An operator stack ⇒ Infix to (Postfix or Prefix)
An operand stack ⇒ Postfix to Prefix
Operator & operand stack ⇒ We don't use two stacks
Parse tree ⇒ No use
An operand stack ⇒ Postfix to Prefix
Operator & operand stack ⇒ We don't use two stacks
Parse tree ⇒ No use
Question 2 |
To evaluate an expression without any embedded function calls
One stack is enough | |
Two stacks are needed | |
As many stacks as the height of the expression tree are needed | |
A Turning machine is needed in the general case |
Question 2 Explanation:
To evaluate an expression or converting prefix to postfix, postfix to prefix only one stack is enough.
There are 2 questions to complete.