Priority Queues in STL #include <iostream> Binary heap #include <queue> using namespace std; Maintains maximum int main () element { Methods priority_queue<int> Q; for (int i=0; i<100; i++) Push, top, pop, Q.push(i); while (! Q.empty()) empty, clear { cout << Q.top() << endl; Q.pop(); } } 60
Priority Queues in STL Binary heap Maintains maximum element Methods Push, top, pop, empty, clear #include <iostream> #include <queue> using namespace std; int main () { priority_queue<int> Q; for (int i=0; i<100; i++) Q.push(i); while (! Q.empty()) { cout << Q.top() << endl; Q.pop(); } } 60
ADS-AUK-UNIT-3.docx