0% completed
Could someone explain what this variable definition (in C++ solution) does: pri...
Athanasios Petsas
Feb 16, 2022
Could someone explain what this variable definition (in C++ solution) does: priority_queue, greater> minHeap; ? the greater is a functor, right? To me it seems like applying the greater functor for all the elements of a priority queue. Is it like having a maxHeap and through this greater functor we are turning it into a minHeap?
0
0
Comments
Design Gurus4 years ago
yes, std::greater would cause the smallest element to appear as the top().
Athanasios Petsas4 years ago
Thanks! It makes sense!
Athanasios Petsas4 years ago
will this introduce some overhead comparing to maxHeap, since it manipulates the vector? Does it do it every time?
Design Gurus4 years ago
Each priority queue has a comparing function. The default implementation is for max heap. Please see the documentation for details.
Athanasios Petsas4 years ago
I checked it out, thanks!
On this page