Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

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;
}
Source by softwareengineering.stackexchange.com #
 
PREVIOUS NEXT
Tagged: #Priority #Queue #Min #Heap
ADD COMMENT
Topic
Name
8+2 =