Quote (carteblanche @ Feb 4 2013 12:39am)
explain it in more detail until you understand it. how is it that a peak is constant time and insert/delete are logarithmic? then answer the question you asked me.
peek just finds the root, so it is O(1)
Insert/delete however are based on the number of levels of the heap, therefore the time complexity is O(Log(n))
for delete you have to take the last element on the last level and replace it with the previous root, then you have to make sure it is in the correct order
This post was edited by Eep on Feb 3 2013 11:55pm