why is the syntax as follows: ,
priority_queue<int,vector,greater> pq;
why is vector used?
Unable to understand syntax for minheap
@mayankA47 priority_queue of STL supports a constructor that requires 2 extra arguments to make it a min heap. The two extra arguments are vector < int > , greater < int >. So in order to use min heap from c++ standard template library, you will have to use such syntax. If the extra arguments are not used, by default a max-heap would be formed.
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.