Answers for "Priority Queue using Min Heap in c++"

C++
16

min heap in c++

priority_queue <int, vector<int>, greater<int>> minHeap;
Posted by: Guest on August-02-2020
0

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;
}
Posted by: Guest on December-08-2020

Code answers related to "Priority Queue using Min Heap in c++"

Browse Popular Code Answers by Language