Back to Browse

Binary Min/Max Heap Insert Overview

89.5K views
Mar 30, 2019
2:56

In this tutorial we're going to be going over how we can insert data within our binary heap. The first step is always to insert at the last available position within our heap. The 2nd step depends on whether or not we're implementing a min or max heap. For a minimum heap we compare the data we just inserted, to its parents. If its smaller than the parent, we just swap. We continue to do this, up until the root node. The same is true for a maximum heap, except in reverse. We compare the data we just inserted, to its parent. If its greater than its parent, we swap. We continue to do this, up until the root node.

Download

1 formats

Video Formats

360pmp43.3 MB

Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.