please explain the stl function of priority queue as Im not able to understand the concept in the video
The stl function of priority queue
Hey @aslesha.j7
priority_queue is just like a normal queue except the element removed from the queue is always the greatest among all the elements in the queue, thus this container is usually used to replicate Max Heap in C++. Elements can be inserted at any order and it have O(log(n)) time complexity for insertion.
Im not able to understand the syntax which has been used in the video using stl
@aslesha.j7
priority_queue pq<int, vector, greater> pq(ropes, ropes+ropes.size())
vector and greater parameters are used to make min heap(priority queue)
and putting ropes as parameter pushes element of ropes vector into pq.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.