How does lastline work?
Will it make max heap or min heap?
int myints[] = {10,20,30,5,15};
std::vector<int> v(myints,myints+5);
std::make_heap (v.begin(),v.end());
How does lastline work?
Will it make max heap or min heap?
int myints[] = {10,20,30,5,15};
std::vector<int> v(myints,myints+5);
std::make_heap (v.begin(),v.end());
std::make_heap is part of the "heap" functions in the standard library. They all work by using an underlying data store. In the case you gave you are using a std::vector
as your data store.
Calling std::make_heap
passing in the range of your data store will heapify its contents, causing the first element to the largest in value and satisfying all requirements for std::push_heap and std::pop_head.
How does lastline work ? will it make max heap or min heap?
It makes a max heap within the std::vector
supplied (v).