
Heap Data Structure (max and min)- Beau teaches JavaScript
video description
Date: 2022-03-14
Related videos
Comments and reviews: 9
Dave
While I appreciate the info, why did he choose to show the diagram for a max heap and then walk through the code of a min heap? He even showed us that he has the code for a min heap already there, so why show one thing and explain how to build the opposite? Even more nonsensical, he leaves the diagram of the max heap side by side the whole time he's walking through the code of the min heap. Anyone who wants a visual representation of the min heap while he explains the code has to ignore the diagram displayed side by side with the code.
reply
While I appreciate the info, why did he choose to show the diagram for a max heap and then walk through the code of a min heap? He even showed us that he has the code for a min heap already there, so why show one thing and explain how to build the opposite? Even more nonsensical, he leaves the diagram of the max heap side by side the whole time he's walking through the code of the min heap. Anyone who wants a visual representation of the min heap while he explains the code has to ignore the diagram displayed side by side with the code.
reply
Ranesh
shouldn't we replace the -- with and && here:
if(heap[left] == undefined -- heap[right] == undefined)-
break;
-
be this instead:
if(heap[left] == undefined && heap[right] == undefined)-
break;
-
because we still want to swap even if the parent has only -one- child.
reply
shouldn't we replace the -- with and && here:
if(heap[left] == undefined -- heap[right] == undefined)-
break;
-
be this instead:
if(heap[left] == undefined && heap[right] == undefined)-
break;
-
because we still want to swap even if the parent has only -one- child.
reply
berkin
Thank you Beau. My question is; when you sort the heap, you also remove everything in the actual heap. Is this expected? I mean, if I sort it and then insert another element, the heap will have only 2 elements; the null and the last thing I added.
reply
Thank you Beau. My question is; when you sort the heap, you also remove everything in the actual heap. Is this expected? I mean, if I sort it and then insert another element, the heap will have only 2 elements; the null and the last thing I added.
reply
Ebrahim
This is wrong, because if there is an element in the left, then we need to check
if (this.heap[left] == undefined -- this.heap[right] == undefined) -
break;
-
reply
This is wrong, because if there is an element in the left, then we need to check
if (this.heap[left] == undefined -- this.heap[right] == undefined) -
break;
-
reply
Tyler
at 10:38, in the remove function you use .splice(heap.length-1); to splice off the last element of our array..
is it faster to use splice instead of a .pop(); there?
reply
at 10:38, in the remove function you use .splice(heap.length-1); to splice off the last element of our array..
is it faster to use splice instead of a .pop(); there?
reply
Michael
if we cut off the last element on line 57, we would be left with just the array with one element in is which is null, then why are we cutting it off?
reply
if we cut off the last element on line 57, we would be left with just the array with one element in is which is null, then why are we cutting it off?
reply
---
-this._heap[left] === undefined -- this.heap[right] === undefined-
I think -- sign should be && sign and other logic should be changed respectively
reply
-this._heap[left] === undefined -- this.heap[right] === undefined-
I think -- sign should be && sign and other logic should be changed respectively
reply
LobsterCanary
I'm sorry, but this video is not very helpful. There's not one word about WHY heaps are used, so I'm not given any incentive to learn HOW.
reply
I'm sorry, but this video is not very helpful. There's not one word about WHY heaps are used, so I'm not given any incentive to learn HOW.
reply
Caroline
Super helpful, thanks Beau for all of your contributions. All of your Data Structure videos are fantastic. Been sharing them with my cohort!
reply
Super helpful, thanks Beau for all of your contributions. All of your Data Structure videos are fantastic. Been sharing them with my cohort!
reply
Add a review, comment
Other channel videos















