6 votes 6 votes A queue is implemented using 2 stacks. Minimum no. of stack operations (PUSH and POP) required for the sequence of 3 insertions and 2 delete operations in the queue is ------- . DS stack queue data-structures + – SSrawat asked Oct 9, 2017 SSrawat 6.0k views answer comment Share Follow See all 2 Comments See all 2 2 Comments reply Himanshu Kumar Gupta commented Aug 25, 2020 reply Follow Share i think 11 stack opreation are needed push = 6 pop = 5 0 votes 0 votes Rakmo commented Jan 4, 2023 reply Follow Share Ig it was 10 total operations Push and pop both are same ! Plzz correct me if i was wrong ! 0 votes 0 votes Please log in or register to add a comment.
8 votes 8 votes Suppose 3 insertions are A,B,C Queue is FIFO ordered data structure but according to (i) it is not FIFO its LIFO SO we popped out all elements from 1 stack to another as (ii) now if we pop elements it will follow FIFO order So Push Pop (in Stack 1) 3 (A,B,C) 3(C,B,A) ( in Stack 2) 3 (C,B,A) 2 (as mentioned) A,B Total 6 5 Push + pop = 11 Reference :-https://www.youtube.com/watch?v=x0_9uVLQ7SI Rishi yadav answered Oct 9, 2017 Rishi yadav comment Share Follow See 1 comment See all 1 1 comment reply Ajay Prakash Verma commented Oct 26, 2017 reply Follow Share Simple and Effective Explanation.. 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes First push 3 elements in stack 1- 3 Push Then pop and push them in 2nd stack- 3 Pop+3Push Then pop 2 elements- 2 Pop Total=11 Purvi Agrawal answered Oct 9, 2017 Purvi Agrawal comment Share Follow See all 0 reply Please log in or register to add a comment.