Question-42

Data Structure
Stack
Queue

Let S be a stack and Q be a queue supporting the following operations:

Stack operation:

Queue Operation:

Suppose initially elements A, B, C, D, E, F and G are pushed onto stack S in reverse order, i.e., starting from G.

The following sequence of operations is performed on stack S and queue Q:

Q.Enqueue(S.Pop())
Q.Enqueue(S.Pop())
Q.Enqueue(S.Pop())
Q.Enqueue(S.Pop())
Q.Enqueue(S.Pop())
S.Push(Q.Dequeue())
S.Push(Q.Dequeue())
Result = S.Pop()

What would be the value of Result after completion of operations ?