![if !IE]> <![endif]>
State and explain the priority queue with example. Priority Queue
- is a queue where each data has an associated key that is provided at the time of insertion. - Dequeue operation deletes data having highest priority in the list
- One of the previously used dequeue or enqueue operations has to be modified
Example: Consider the following queue of persons where females have higher priority than males (gender is the key to give priority).
Dequeue()- deletes Aster Dequeue()- deletes Meron
Now the queue has data having equal priority and dequeue operation deletes the front element like in the case of ordinary queues.
Dequeue()- deletes Abebe Dequeue()- deletes Alemu
Thus, in the above example the implementation of the dequeue operation need to be modified.
Copyright © 2018-2023 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.