priority queue using heap 1

priority queue using heap

#include
std::priority_queue , std::greater > minHeap; 

Here is what the above code is Doing:
1. We are creating a priority queue named minHeap.
2. The priority queue is a max heap by default.
3. We are passing three template arguments to the priority queue.
4. The first template argument is the type of data that the priority queue will store.
5. The second template argument is the underlying container that will be used to store the data.
6. The third template argument is the comparison function that will be used to compare the elements.
7. We are using the std::greater comparison function which will make the priority queue a min heap.

Similar Posts