I am trying to build a min heap using the library function make_heap .Please point out the error in the class compare. The root element should have been the minimum element in the array but it is not.
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;
class compare {
bool operator()(pair<int, int> lhs,pair<int, int> rhs) const
{
return lhs.second < rhs.second;
}
};
int main()
{
int arr[]={9,2,5,7,3,5,7,5,4,5,6,4,5};
make_heap(arr,arr+13,compare);
cout<<arr[0];
}