2 2 votes 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? Data Structures data-structures stack queue + – himgta 1.2k views answer comment Share Follow Print 0 reply Please log in or register to add a comment.
3 3 votes I think if we use 2 simultaneous push operations we will end up in a infinite loop sathvikchiramana answered Jul 18, 2018 sathvikchiramana comment Share Follow 0 reply Please log in or register to add a comment.
0 0 votes for 2 push- 2 en-queue for 2 pop- infinite en-queue and infinite de-queue rish1602 answered Feb 5, 2021 rish1602 comment Share Follow 0 reply Please log in or register to add a comment.