Heap - Data Structures in Javascript

preview_player
Показать описание
Introduction to Heap data structure. We will cover:
1) The definition of Heap/Binary Heap
2) Push and poll methods
3) Dealing with array indexes
4) Main and additional heap methods
5) Big O for insertion, deletion, search and poll
5) Implementation of a max-heap in Javascript
Рекомендации по теме
Комментарии
Автор

Best explanation of heap implementation in JS. Cheers!

cobainsick
Автор

I checked out different videos for Binary Heap....yours was the best. Thanks.

HemantSingh-prhd
Автор

It was great, thanks for your efforts 👍

Krishnasharma-efxf
Автор

I accidentally removed a very nice question on why does left child's index equal i * 2 + 1 and not just i * 2. The answer is that our indexes are 0-based.
Imagine a tree:
0
/ \
1 2
/ \ / \
3 4 5 6

If our i = 1, the left child's index will be 1 * 2 + 1. And the right children's index will be 1 * 2 + 2

Sorry for removing the question, I just wanted to edit my answer :D. If it is still not clear, please respond and we'll discuss it.

QuestionableCoding
Автор

Great explanation. How can I change this code to min-heap?

carefree_ladka
Автор

5:33 Looking at the array visualization this looks like badly sorted sequence. It somewhat resembles the graph above as I can see how one can move from graph to that array, but cannot imagine how to build a graph from that array.

ЭдуардСухарев-шч
Автор

Why is Heap supposed to be effective for priority queue? Is it because main operations are polling the top and popping the bottom elements and there's no traversal to see that it's not properly balanced all the way through?

ЭдуардСухарев-шч
Автор

Came here to learn heap, but learned "hip" data structure

jiren
welcome to shbcf.ru