priority_queue <int, vector, greater> gquiz;
why minHeap declaration is like the above line and whereas for maxHeap it is:
priority_queuepq; ?
priority_queue <int, vector, greater> gquiz;
why minHeap declaration is like the above line and whereas for maxHeap it is:
priority_queuepq; ?
by default priority queue is max heap
so to create max heap we have write simply
priority_queue < int > pq;
but to create min heap we have to pass own comparator and vector as well like
priority_queue <int, vector, greater< int >> gquiz;
here greater is comparator
why are passing vector actually?
actually it is the part of syntax we have to pass this
may be this is used to store min heap but i am not sure
because it is not mention anywhere it is a adaptor conatiner