693 views
1 1 vote
Consider implementation of stack using queue by following algorithm.
Let x be an element to be pushed in the stack.
push(q1, x) {
    EQ(q1,x)
    
    while (q1 does not contain 1 element) {
k= DQ(q1)
EQ(q1,k)
           }
}
pop(q1) {
    DQ(q1)
}

How many enqueue and dequeue operations required to push 2 and pop 2 elements in the empty stack?

Please log in or register to answer this question.

Position:
Show:

No related questions found