1. Intro to priority queue #
Created Wednesday 12 February 2020
Selecting Items #
Suppose that we have people in a queue. How to select a candidate can be decided in the following:
- Time(known as FCFS) i.e a normal FIFO queue.
- VIP factor - By an authority.
- Criticality - Natural, e.g old age, medical condition.
There can be two types of queues:
- Min - Minimum valued exits first.
- Max - Maxiumum valued exits first.
Priority queue ADT #
- push() aka insert()- insert value. It is placed w.r.t the criteria.
- top() aka getMax()/getMin() - return the value at top, minimum(in case of min-heap) and maxiumum(in case of max-heap).
- pop() aka removeMin()/removeMax() - Removes and returns an element.
Which data structure to use for this task:
Balanced BST is the best here.