We can learn the big-O of building a binary heap using recursive method is O(n log n) from wiki "This approach, called Williamsβ method after the inventor of binary heaps, is easily seen to run in O(n log n) time: it performs n insertions at O(log n) cost each.[a]" we can also know if we build the heap using other methods. the big O could be better. Where should we begin if we would like to prove that the performance, Big Omega ,of building a binary heap using recursive method is Ξ©(nlog(n)), which is same as Big-O?
insert method from wiki
To add an element to a heap we must perform an up-heap operation (also known as bubble-up, percolate-up, sift-up, trickle-up, swim-up, heapify-up, or cascade-up), by following this algorithm:
Add the element to the bottom level of the heap. Compare the added element with its parent; if they are in the correct order, stop. If not, swap the element with its parent and return to the previous step
then we have the buildheap as
buildheap((π1,πΎ1),(ππ,πΎπ))
if n==1:
return [(π1,πΎ1)]
return insert((ππ ,πΎπ),buildheap((π1,πΎ1),...(ππβ1,πΎπβ1))