Heap Delete

August 25, 2016

Deleting a node in a min-heap

One of the assignments for Bloc's SET program involves creating CRUD methods in Ruby to build a heap and tear it down again. I am using a min-heap for reference.

There are a ton of online references with illustrations on how to delete a node in a heap. In essence, the credited response is that you swap out the right-most node on the bottom row with the now-empty target. Then you proceed to swap either up or down to re-heap / heapify / whathaveyou so that each row's items, in the case of a min-heap, is smaller than any given item in the row that follows.

Note that the measure of what constitutes smaller is itself a little confusing but no matter.

Emory U's Heap Delete logorithm page U. of Alberta's Heap Delete Page Clemson's Heap Delete Page Some dude on YouTube