I am wondering why for creating a min heap using the priority_queue
, the std::greater
should be used?
std::priority_queue<T, std::vector<T>, std::greater<T> > min_heap;
To me, since the smallest value is always located at the top of the heap, the employed class should be std::less
Update:
On the other hand, since the default behavior of priority_queue
(max heap) is to hold the greatest value at the top, it looks to me that the std::greater
should be used for the max heap creation and not for min heap creation