using priority queue c++ code example
Example 1: implemetation of priority queue in c++
priority_queue<int> pq;
priority_queue <int, vector<int>, greater<int> > pq;
#define pp pair<int, int>
priority_queue <pp, vector<pp>, greater<pp> > pq;
Example 2: Priority Queue using Min Heap in c++
#include <bits/stdc++.h>
using namespace std;
int main ()
{
priority_queue <int> pq;
pq.push(5);
pq.push(1);
pq.push(10);
pq.push(30);
pq.push(20);
while (pq.empty() == false)
{
cout << pq.top() << " ";
pq.pop();
}
return 0;
}