logo

Crowdly

Browser

Add to Chrome

We use 2 stacks,  stack1   and  stack2  with the following initial states ...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

We use 2 stacks, stack1  and stack2 with the following initial states

stack1: 17 is on the 'top' of the stack: this is the first element to be unstacked()/popped()

stack1->172-1xx9+

stack2 is empty

we use the following algorithm:

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?

0%
0%
0%
0%
More questions like this

Want instant access to all verified answers on moodle.myefrei.fr?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome