Quote (carteblanche @ Feb 4 2013 01:00am)
explain this process. how do you make sure it's in the correct order? and what order is correct? a comparison sort cannot be faster than nlogn. so how are you getting logn for the entire deletion process if the sort alone is nlogn?
The process is:
For example, if you replace the root of a max heap
lets say the old root was n and its children are n1 and n2
if you replace n with the lowest level last entry n3 and n3 >= n1 && n2, then you can just stop
however, if replacing n with n3 means that n1 or n2 is suddenly >= n3, then you have to swap it with the LARGER of the 2 children until it satisfies the heap property you want (in this case, max heap?)
apparently there is an algorithm called the max-heapify function which is used here