1 votes 1 votes What are the minimum number of pointers required to implement a stack using single ended queue ( the queue is NOT a dequeue )? DS stack queue data-structures pointers + – kapilbk1996 asked Jul 26, 2018 kapilbk1996 1.1k views answer comment Share Follow See 1 comment See all 1 1 comment reply Adittya commented Sep 24, 2018 reply Follow Share i think 2 , cause if u take 1 pointer then how will get to know whether queue is full or not i have a doubt that ur question is incomplete 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes As per I think... Its 2 (FRONT and REAR) (If u r thinking of having single pointer then it will not be a queue anymore bcoz queue has enqueue and dequeue operations in constant time). amit srivastava answered Aug 8, 2018 • edited Aug 9, 2018 by amit srivastava amit srivastava comment Share Follow See all 3 Comments See all 3 3 Comments reply MiNiPanda commented Aug 8, 2018 reply Follow Share I think we need two queues to implement a stack..then shouldn't we consider two sets of front and rear pointer for the two queues? Then total will be 4.. 2 votes 2 votes amit srivastava commented Aug 8, 2018 reply Follow Share true , but thats a bruteforce approach. If we are talking about minimum then one more solution is possible. Try to keep the latest inserted element at the Front pointer. 1: Insert x at rear node 2: perform dequeue followed by enqueue until x reaches the FRONT. 0 votes 0 votes DAWID15 commented Dec 23, 2021 reply Follow Share I was thinking the same. In that case we can get away with just one queue. However for this to work I think the queue should be circular queue. Otherwise we will quickly reach to the end of queue and no more enque will be possible. 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes since there is no Dequeue then we need three pointers rish1602 answered Feb 2, 2021 rish1602 comment Share Follow See all 0 reply Please log in or register to add a comment.