Definition
A priority queue is an abstract data structure consisting of elements that have an associated value called a key or priority that carries the following operations:- Insert(Q,x): insert element x in the priority queue Q;
- ExtractMax(Q): extracts the maximum value element from the priority queue Q.
Observation!
Analogously, a min-priority queue can be defined, and we are interested in extracting the minimum priority element from the queue.There are many applications of priority queues. For example, scheduling the execution of programs on a computer: the priority queue holds the programs to be executed according to their relative priorities. When the execution of a program ends or is interrupted, the program with the highest priority in the queue is selected and launched(operation ExtractMax). Adding a new program to the queue is done with the operation Insert.