Storing the heap in the form of an array just blew my mind...so effective
The calculation shown in the cartoon diagram to get the parent of the node is shown as (index-2)/2. In the code the calculation is (index-1)/2.
Clean implementation. Clean explanation. Wonderful video! Thank you very much for taking the time to make this. I really needed it!
The explanation with the code is amazzing !! loved it....seems that would work for me! Please continue with the good work
Just an FYI: At 3:01 timeframe, you are showing formulas and for pareint you have [Index -2) / 2]. This needs to be change dto index -1 * 2. On next screen where you are coding it, you have it right.
If you're trying to write this code in Python, beware: You cannot simply assign items[0] = items[self.size - 1]. You must pop() the item at the end of the list to remove it: items[0] = items.pop() ... also be sure to use floor division in the parent calc if using Python 3: (index - 1) // 2
Having that visual next to the code is such a godsent, thank you for saving my bachelors degree
The best explanation of heaps ever, it got me first try.
Best video explanation with code walkthrough showing how to answer the ubiquitous lazy interviewer question "Implement a Heap data structure".
3:22 "Aaand there we go, we've created Minecraft!"
Pro tip: if your array is indexed at 1 (like with Fortran) the pointers are parent: (index-1)/2, left child:2*index, right child:2*index +1
I forgot this channel existed. It saved me once again
I read about heaps online and first implemented it using a right and left Node. I felt array, though - spidey senses. I wish I would have seen it on my own. But, this video was a close second. Thank you so much for a clear description.
This is a really nice explanation of min heaps.... Very nice, very clear, very simple , concise and short enough to pick up in a jiffy. Thanks Gayle.
When I clicked on this video I had no idea I'd be learning from the legend herself. Damn.
Thanks a lot, Madam. I've been burning out myself scrolling numerous websites not getting how a heap actually works and how it's implemented, and now finally implemented successfully in C#.
Her keyboard clicks are the most satisfying sound
Heaps can be thought of as a binary tree. Peek takes O(1) while other operations take O(log n). For min heap: 1) Insert new node at last, then heapify (ie swap with parent until parent > child) 2) Delete the root node, replace last element at root then heapify (ie swap down)
I am translating these lessons for use in Unreal Engine Visual Blueprints, and Gayle delivers these lessons very cohesively. Thank You!
@WorklLife