Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 2
    $\begingroup$ Taking down the heap is not really the reverse of heapify, it is the reverse of starting with an empty heap and adding elements one by one. Both of these are n log n $\endgroup$ Commented Mar 21, 2020 at 13:28
  • $\begingroup$ @MatthewC building a heap is really O(n). See en.wikipedia.org/wiki/Binary_heap#Building_a_heap $\endgroup$ Commented Mar 21, 2020 at 13:52
  • 1
    $\begingroup$ What do you mean by "take down"? Note that building heaps in linear time is not accomplished by repeated "push". $\endgroup$ Commented Mar 21, 2020 at 16:27
  • $\begingroup$ @nonpolarity That is heapify (makeHeap, or whatever you like to call the process of transforming an array into a heap). $\endgroup$ Commented Mar 21, 2020 at 16:51