Complete the code to declare a priority queue of integers in C++.
std::priority_queue<int> [1];The standard name for the priority queue variable here is pq. This declares a priority queue of integers.
Complete the code to insert the integer 10 into the priority queue named pq.
pq.[1](10);
insert which is not a method of priority_queue.enqueue which is used in other queue types.In C++, the method to add an element to a priority queue is push.
Fix the error in the code to get the top element from the priority queue named pq.
int topElement = pq.[1]();front() which is for other queue types.peek() which is not a C++ priority queue method.The correct method to access the highest priority element in a C++ priority queue is top().
Fill both blanks to remove the top element from the priority queue and then check if it is empty.
pq.[1](); bool empty = pq.[2]();
push() instead of pop() to remove elements.size() to check emptiness instead of empty().Use pop() to remove the top element and empty() to check if the priority queue is empty.
Fill all three blanks to create a min priority queue of integers using C++ STL.
std::priority_queue<int, std::vector<int>, [1]> [2]; [2].push(5); [2].push(1); [2].push(3);
std::less<int> which creates a max priority queue.To create a min priority queue, use std::greater<int> as the comparator. The variable name is minPQ, used consistently.
