I am looking how to build a heap in O(n) time and I found it using Heapify. But I wonder whether the STL priority_queue do the same? So my question is:
Which method of build heap is used by priority_queue available in STL? Is it using the heapify which can turn the whole array to heap in O(n) or using one by one insertion of elements in heap taking O(n log n) time?
I am guessing it to be 2nd method as we manually insert elements one by one when using STL priority_queue. Am I correct?
O(N)complexity.O(N)in general,make_heapneeds to be smarter than that to achiveO(N)