✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
| stack1-> | 17 | 2 | -1 | x | x | 9 | + |
|---|
while stack1 is not empty
value <- pop(stack1) if value is a number push(stack2, value) else (value is an operator, addition or mulitplication) val1 <- pop(stack2) val2 <- pop(stack2) result <- apply the operator to val1 and val 2 (val1+val2 if it's an addition, val1 x val2 if it's a multiplication) push(result, stack2)
what value will be stored in stack2 at the end of the algorithm?