1 1 vote Hi please verify me We can implement a stack using only one queue. Like first insert into queue and for popping a element from stack dequeue n-1 element from queue and enque into queue and then pop last element and do the same each time......try it and verify that I am right or wrong? Programming in C data-structures queue stack + – Ravi prakash pandey 1.6k views answer comment Share Follow Print See 1 comment 1 1 comment reply AskHerOut commented Apr 7, 2018 reply Follow flag yes, assuming you know the size of stack/queue at each point. reference: https://www.geeksforgeeks.org/implement-a-stack-using-single-queue/ 3 3 replyShare Please log in or register to add a comment.
1 1 vote please verify ur self first that when ur are doing n-1 dequeue where r u storing them .....nd now after popping desired element from where u r picking those n-1 elements to enqueing the into queue for further iterations......................... eyeamgj answered Apr 7, 2018 eyeamgj comment Share Follow See all 2 Comments 2 2 Comments reply Ravi prakash pandey commented Apr 7, 2018 reply Follow flag no it is possible.....when i m doing dequeue then i m inserting that element at the tail of queue also. please do it on pen and paper 0 0 replyShare Shubham Yadav commented Apr 7, 2018 reply Follow flag Lets suppose size of queue in of n elements only , then i want to perform stack op , now according to u for pop first element u have to dequeue other n-1 elements ,now here is point where u will store all u have only place vacant. 0 0 replyShare Please log in or register to add a comment.