1 1 vote How many minimum queues are required to implement a priority queue? Data Structures priority-queue data-structures + – tripathiambuj 2.2k views answer comment Share Follow Print 0 reply Please log in or register to add a comment.
2 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 4 4 Comments reply junk_mayavi commented Dec 20, 2017 reply Follow flag Can we store priority and data in the same queue using structure nodes? why we go for 2 queues? 0 0 replyShare Xylene commented Dec 20, 2017 reply Follow flag @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 0 replyShare junk_mayavi commented Dec 20, 2017 reply Follow flag @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 1 replyShare Mk Utkarsh commented Dec 21, 2017 reply Follow flag 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 1 replyShare Please log in or register to add a comment.