In: Computer Science
What are the differences between a maximum priority queue and a minimum priority queue?
There are two types priority queues:
max priority queue
min priority queue
In both type, priority queue stores elements and is always able to provide the most extreme element.
Differences
Max priority queue is based on the structure of max heap while min priority queue is based on min heap.
In max priority queue, max element from the list is stored as an first element while in min priority queue, min element from the list is stored as an first element.
Operation of max priority queues are
maximum(A) - returns max element from A.
extract_maximum(A) - removes and returns max element from A.
increase_val(A, i, val) - Increses key of element stored at i in A to new value val.
insert_val(A, val) - inserts element with val in A.
remove() - it removes max element
Operation of min priority queues are
minimum(A) - returns min element from A.
extract_minimum(A) - removes and returns min element from A.
decrease_val(A, i, val) - decreses value of element at i in A to val.
insert_val(A, val) - inserts element with val in A.
remove() - it removes min element