(Solved):Imagine you have a stack of integers, S, and a queue of integers, Q. Draw a picture of S and Q after the following operations in the C language: 1. pushStack (S, 3) 2. pushStack (S, 12) 3. enqueue… View Answer…

 

Question

Imagine you have a stack of integers, S, and a queue of integers, Q. Draw a picture of S and Q after the following operations in the C language:

1. pushStack (S, 3)

2. pushStack (S, 12)

3. enqueue (Q, 5)

4. enqueue (Q, 8)

5. popStack (S, x)

6. pushStack (S, 2)

7. enqueue (Q, x)

8. dequeue (Q, y)

9. pushStack (S, x)

10. pushStack (S, y)

 

EXPERT ANSWER

The stack operations are

  1. Push(3)
  2. Push(12)
  3. Pop() store in x
  4. Push(2)
  5. Push(x)
  6. Push(y) (value of y acquired
Scroll to top