1 votes 1 votes How many minimum queues are required to implement a priority queue? DS priority-queue data-structures + – tripathiambuj asked Jun 22, 2016 • edited Sep 11, 2016 by sourav. tripathiambuj 1.5k views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
2 votes 2 votes Priority queue has the priority associated with each element. so 1 queue will store the elements and 2nd queue will give the priority to the elements which are stored in the queue. we will need 2 queues Kapil answered Jun 22, 2016 Kapil comment Share Follow See all 4 Comments See all 4 4 Comments reply junk_mayavi commented Dec 20, 2017 reply Follow Share Can we store priority and data in the same queue using structure nodes? why we go for 2 queues? 0 votes 0 votes Xylene commented Dec 20, 2017 reply Follow Share @junk_mayavi, you can do that but there will no improvement in terms of space and time complexity. (It will be same as the one with two queues). 0 votes 0 votes junk_mayavi commented Dec 20, 2017 reply Follow Share @Xylene that reduces the minimum number of queues down to 1 isn't it? but if they provide conditions in question such as derived data types should not be used, then the answer will be 2. 1 votes 1 votes Mk Utkarsh commented Dec 21, 2017 reply Follow Share A struct is user defined data type if you are using a struct it is grouping different types so that doesn't mean there is a single queue there are still 2 queues. 1 votes 1 votes Please log in or register to add a comment.