Binary Min/Max Heap Insert Overview

preview_player
Показать описание
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.
Рекомендации по теме
Комментарии
Автор

This video helped me pass my Data structures and Algorithms course, thank you Legend :D <3 I am free!

KALIMAindia
Автор

Very nice please keep making in depth algorithms and data structure videos

frownless
Автор

I LOVE YOU PEDRO THANK YOU FOR MAKING THIS!!!!

Quakies
Автор

Plz could you answer: can we use build max heap using insertion on a for loop starting from 1, if not why?

boutbout
Автор

I don't know why they call it the last available position, it is actually the first.

MrBreadfan