What Is a Binary Heap?

แชร์
ฝัง
  • เผยแพร่เมื่อ 17 ม.ค. 2025

ความคิดเห็น • 189

  • @MrAngryNeard
    @MrAngryNeard 4 ปีที่แล้ว +281

    I have learnd more in 8 min with you than 2 h in the university.

    • @playanakobi4407
      @playanakobi4407 3 ปีที่แล้ว +16

      agree. it's so different when they explained first why you're doing this than focusing on how to do it.

    • @superannoymous5731
      @superannoymous5731 3 ปีที่แล้ว +5

      True, GOD! it is frustrating when my lecturer would give us homework first before explaining which make the whole thing pointless.

    • @maxdemian6312
      @maxdemian6312 2 ปีที่แล้ว +1

      this

    • @jkrigelman
      @jkrigelman 2 ปีที่แล้ว +5

      Or is it because you already learned it for two hours and it's easier with a new visual explanation it makes sense now? 🤔
      I'm visual so it may be the video.😁

    • @horaciomlhh
      @horaciomlhh ปีที่แล้ว

      Different styles make people learn more!

  • @BrianOSheaPlus
    @BrianOSheaPlus ปีที่แล้ว +66

    This is a good explanation. It's also worth mentioning that the time complexity of this algorithm is log(n) for inserts and deletes. For example, when you add a new node, it will only have to be swapped at most log(n) times, where n is the total number of nodes in the tree.

    • @NachitenRemix
      @NachitenRemix ปีที่แล้ว +3

      Yeah, log(n) is basically the depth (amount of rows) of the heap, so that makes sense.

    • @alpharudiger1193
      @alpharudiger1193 7 หลายเดือนก่อน

      @@dominiquefortin5345 isnt he finding it by having a counter in every node?

    • @dominiquefortin5345
      @dominiquefortin5345 6 หลายเดือนก่อน +1

      @@alpharudiger1193 No he keeps 2 in each nodes. One for the right subtree and one for the left subtree. Not very efficient.

  • @nguyentrieta
    @nguyentrieta 3 ปีที่แล้ว +115

    At 4:25, I think the insertion is wrong. We always add it to the leftmost en.wikipedia.org/wiki/Binary_heap#Insert

    • @vorun
      @vorun 3 ปีที่แล้ว +8

      Agree! Insertion is wrong.

    • @znacloudznacloud8568
      @znacloudznacloud8568 2 ปีที่แล้ว +2

      Agree

    • @georgiatanasow6658
      @georgiatanasow6658 ปีที่แล้ว +5

      Maybe you missed that part, but he said that we want our binary heap to be perfectly balanced. In that case the insertion showed in the video is correct.

    • @Yazan_Majdalawi
      @Yazan_Majdalawi ปีที่แล้ว +3

      @@georgiatanasow6658 Why though? is there a benefit for doing it that way, compared to the easy way of filling the level from left to right?

    • @amitdhaterwal8395
      @amitdhaterwal8395 ปีที่แล้ว +1

      @@Yazan_Majdalawi we are trying for perfectly balance, suppose we have imbalance by factor 1 (suppose height(left)-1 === height(right)), now if we are inserting a new node, if we insert it to left again then the factor will still be 1, but if we insert to the right our factor will be zero and heap will be perfectly balanced
      The complete binary tree shape is also a valid but the balance factor can be 1 (which is allowed).

  • @carlbutcher2268
    @carlbutcher2268 10 หลายเดือนก่อน +2

    I missed a lecture at university the other week and ended up doing a test without having any idea what a heap was or how it worked; Your video is clear and easy to understand, and I wish I'd looked sooner. Thank you.

  • @cyril3248
    @cyril3248 ปีที่แล้ว +52

    I'm more familiar with the implementation as a complete tree ("filling each level from left to right") as it's easier to implement in a vector which eploits the contiguity in memory. This more AVL styled implementation is still interesting I have to say

    • @rektdedrip
      @rektdedrip ปีที่แล้ว +2

      This was my first time seeing an AVL type of implementation for a heap. I was always taught the complete tree structure as well

    • @angeldude101
      @angeldude101 10 หลายเดือนก่อน

      Somewhat amusingly, this has the same flaw that the video gave for just using an array, but the "flaw" in question is so minor that it's still usually more efficient than using pointers like in a traditional binary tree or linked list.

    • @dominiquefortin5345
      @dominiquefortin5345 8 หลายเดือนก่อน +1

      @@rektdedrip There is no reason to do the AVL type thing.

  • @krewfit
    @krewfit 3 ปีที่แล้ว +111

    To make a complete binary tree, you go from top to bottom, left to right ALWAYS.
    The insertion in this video is not correct... however, the information he presents is very helpful!

    • @pursadas
      @pursadas 2 ปีที่แล้ว +8

      and also during deletion, the right-most element is sent to the root, isn't it? to preserve the said property?

    • @anushreevirtualgaming226
      @anushreevirtualgaming226 2 ปีที่แล้ว +3

      @@pursadas yes, as far as i remember

    • @jellemiddendorf2572
      @jellemiddendorf2572 2 ปีที่แล้ว +2

      thank you so much, i was learning and checked my results with some homework awnsers and got really confused because the homework only showed the end result not the steps inbetween, know i know it was the left to right thing

    • @kebman
      @kebman ปีที่แล้ว +8

      He isn't making a binary tree, though, but a binary heap. Which looks a lot like a binary tree, but is faster - also because it allows for duplicates.

    • @broccolidiego2053
      @broccolidiego2053 ปีที่แล้ว +8

      Binary tree and Binary heap are different. Both have different usage. A binary tree is for storing data while the binary heap is use primarily for a priority queue, either min or max.

  • @kritonios
    @kritonios ปีที่แล้ว +1

    Amazing video. The most detailed and "to the point" explanation of binary heaps I have seen. Many thanks. Keep it up!

  • @johnle7705
    @johnle7705 3 ปีที่แล้ว +2

    I love the presenter! Explain so well, so concisely!!!!

  • @gold4963
    @gold4963 3 ปีที่แล้ว +9

    Easily a 5 star video. You've earned a sub, my friend.

  • @wanwanan6322
    @wanwanan6322 9 หลายเดือนก่อน

    PERFECT video. Not boring and super informative. Covering all exceptions and key concepts. Thank u!

  • @jamilhusssin3792
    @jamilhusssin3792 4 ปีที่แล้ว +10

    please make some more videos on different Algorithms like sorting Array algorithms, greedy algorithms, graphs implementations, etc.

  • @vaibhavpoliwal2820
    @vaibhavpoliwal2820 3 ปีที่แล้ว +3

    Explained in very structured way.

  • @jamaka_me_code796
    @jamaka_me_code796 2 ปีที่แล้ว +2

    Heck yeah I discovered you on CS50 w/David&Doug earlier this year and can't believe I haven't found this yet.! Thanks Brian for EVERYTHING you do homie ✌️

  • @cristeycrouler1027
    @cristeycrouler1027 ปีที่แล้ว

    your way of explaining and the sound of your voice and the type of things you talk about is all so great and makes me watch hours and not feel the time.
    Amazing videos man you deserve much more subscribers, hope you upload more♥️♥️♥️♥️♥️

  • @willabyuberton818
    @willabyuberton818 6 หลายเดือนก่อน

    Really nice video! I could watch animations of values getting inserted and deleted on binary trees all day.

  • @kamoroso94
    @kamoroso94 2 ปีที่แล้ว +2

    Great video! I was looking for a quick refresher to help me implement a priority queue to use in the A* algorithm.

  • @AP_MLB
    @AP_MLB 3 หลายเดือนก่อน

    Amazing how I can learn 20x as much from a 20 minute video than I did in a two hour lecture

  • @AmanSingh-wk3iv
    @AmanSingh-wk3iv 3 ปีที่แล้ว +2

    amazed to see this video in just 8 minutes we need to give at least an hour to learn the same concept at other places .
    Also it is helpful to understand the concept with the real life example so that we also know the applications.
    please create more videos on data structure .
    Thanks!!

  • @kebman
    @kebman ปีที่แล้ว +12

    I'd love a re-visit of this topic, with a comparison of a binary tree, including big O analysis.

    • @coffeedude
      @coffeedude ปีที่แล้ว

      A heap is a kind of binary tree

    • @dominiquefortin5345
      @dominiquefortin5345 8 หลายเดือนก่อน +2

      @@coffeedude Heap is a binary tree.

    • @coffeedude
      @coffeedude 8 หลายเดือนก่อน

      @@dominiquefortin5345 Yeah, it's a specific kind of binary tree. That's what I meant : )

    • @coffeedude
      @coffeedude 8 หลายเดือนก่อน +1

      @@dominiquefortin5345 Yeah, it's a specific kind binary tree. That's what I meant : )

  • @omaryahia
    @omaryahia ปีที่แล้ว +1

    this is clear and concise, thank you 🌟

  • @shandou5276
    @shandou5276 3 ปีที่แล้ว

    This is the best explanation I have seen about heap. Big thumbs up!

  • @ontreprenor
    @ontreprenor 3 ปีที่แล้ว

    Hats off for the graphics. It was very much easy to understand

  • @Leihua_Ye
    @Leihua_Ye 3 ปีที่แล้ว

    this is the best illustration of a binary heap.

  • @zekmaro
    @zekmaro หลายเดือนก่อน

    thanks for explanation. it was so easy to follow. i didnt get heaps and trees but now they look really obvious. thanks man. i was so frustrated now im happy

  • @galiberkowiz594
    @galiberkowiz594 3 ปีที่แล้ว +12

    Thank you for the explanation.
    I was just studying about it during a computer science -Python course on CodeAcademy and they didn't explain what's the real-life usage for this data structure, which is a shame.
    If I'd like to go deeper and understand the process that led to the creation and planning of this data structure, where would you recommend me to read or watch?

    • @dominiquefortin5345
      @dominiquefortin5345 8 หลายเดือนก่อน +1

      But for understanding, code it and play with it. It is only 3 functions insert, delete, size.

  • @abdullahzia4633
    @abdullahzia4633 4 ปีที่แล้ว

    Bruh this was so much better explained than all of the videos with wayyyy more views on YT

  • @charbel4090
    @charbel4090 3 ปีที่แล้ว +6

    BRIAN GET SOME FREE TIME AND UPLOAD AGAIN WE NEED YOU HAHAHAHAHAH I LOVE U

  • @stith_pragya
    @stith_pragya ปีที่แล้ว

    Thank You So Much brother for this wonderful video.....🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻

  • @victorgoncalves8883
    @victorgoncalves8883 3 ปีที่แล้ว +2

    thank you for the help on the CS51 PSET Brian...very much appreciated

    • @kiopsy7591
      @kiopsy7591 8 หลายเดือนก่อน

      @@dominiquefortin5345 whomp whomp

  • @wallinslax
    @wallinslax 3 ปีที่แล้ว +9

    I think the insertion operation at 4:27 might be wrong, since the n th node's child node should be 2n and 2n+1.

    • @DanielVazquez
      @DanielVazquez 3 ปีที่แล้ว +1

      The insertion is definitely not what many and I have learned, but still the invariant that the n-th node's child node should be 2n and 2n+1 remains unchanged.

    • @dominiquefortin5345
      @dominiquefortin5345 6 หลายเดือนก่อน +1

      In an array, yes, but he is using a binary tree.

  • @DamosyTheFreckle
    @DamosyTheFreckle 3 หลายเดือนก่อน

    Amazing explanation and animation. Keep it up

  • @Bhanuteja01
    @Bhanuteja01 6 หลายเดือนก่อน +1

    need all topics of data structure please 😃

  • @utkarshsharma1185
    @utkarshsharma1185 ปีที่แล้ว +1

    Thanks for the clear explanation

    • @dominiquefortin5345
      @dominiquefortin5345 8 หลายเดือนก่อน +1

      Except the information in this video is just so slightly wrong, that people will not know it is bad. So no, it is not Amazing

    • @utkarshsharma1185
      @utkarshsharma1185 8 หลายเดือนก่อน +1

      @@dominiquefortin5345 yeah you are correct, thanks for pointing it out

    • @dominiquefortin5345
      @dominiquefortin5345 6 หลายเดือนก่อน +1

      @@utkarshsharma1185 Let me correct myself. But the author uses a space inefficient way by keeping 2 counter in each node. There are better ways

  • @LaughDimension
    @LaughDimension 5 หลายเดือนก่อน

    thank you very much. very intuitively explained

  • @soroushbieranvand2043
    @soroushbieranvand2043 19 ชั่วโมงที่ผ่านมา

    that is a great explanation thanks

  • @_Shubham....-----------------6
    @_Shubham....-----------------6 ปีที่แล้ว

    The video teaches very much in a short time. Great 👌

  • @Fido1hn
    @Fido1hn 3 หลายเดือนก่อน

    Subscribed! Awesome explanation. ❤

  • @vitorhugodasilvalima859
    @vitorhugodasilvalima859 2 ปีที่แล้ว

    Recognized Brian Yu by voice. Great video, thank you very much, I am your fan

  • @KingofJ95
    @KingofJ95 ปีที่แล้ว

    This actually helped me understand how Heap Sort works.

  • @gdlevels3830
    @gdlevels3830 ปีที่แล้ว

    thank you bro, now i understand more and expand my knowledge with this new type of data structure.
    (really helped in greedy algorithms btw)

  • @Dakshgohil-5
    @Dakshgohil-5 7 หลายเดือนก่อน

    4:42 Where do we add 9th node? Do we add under 5th node or we add under 6th node?

  • @rickbacker1
    @rickbacker1 หลายเดือนก่อน

    Thank you very much for this video!

  • @thedelanyo
    @thedelanyo ปีที่แล้ว

    Priceless lessons

  • @shubhamnagure7654
    @shubhamnagure7654 3 ปีที่แล้ว

    Brian, Thanks for simplifying.

  • @jatinkumar4410
    @jatinkumar4410 3 ปีที่แล้ว

    Amazing and clear explanation...

  • @dodogo777
    @dodogo777 ปีที่แล้ว

    best explaination ever, wish i watched this before my algorithm exam

    • @dominiquefortin5345
      @dominiquefortin5345 8 หลายเดือนก่อน +1

      Except the information in this video is just so slightly wrong, that people will not know it is bad. So no, not good

    • @MohammedAli-p7e9d
      @MohammedAli-p7e9d 6 หลายเดือนก่อน

      ​@@dominiquefortin5345 can you tell me what are the wrong points?
      I am still learning.

    • @dominiquefortin5345
      @dominiquefortin5345 6 หลายเดือนก่อน

      @@MohammedAli-p7e9d The problem is the order of insertion in the video which is 0, 1, 2, 3, 5, 4, 6, 7, 11, 9, 13, 8, 12, 10, 14. You have 2 implementations possible in an array or in a tree. Let’s look at array because it is the simplest. the position of the root is 0, the position of the parent node floor(P/2j, the position of the right child is 2P and the left is 2P+1. The insertion is always made at position N, so always O(1) plus the percolation O(log n) and that garanties the height of the right subtree has at most 1 in difference with the height of the left subtree and the rest is like what you have in the video. So here the order of insertion is 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, … Now the link binary tree implementation in the next comment.

    • @dominiquefortin5345
      @dominiquefortin5345 6 หลายเดือนก่อน

      @@MohammedAli-p7e9d With a binary tree with links, the problem is where to insert a new element. Let’s suppose we put the height of the subtree in each node. Now we will start with a tree that is full on tree level so that all the child nodes of a parent they have the same heights. What rule should we use to find an insertion point? We know percolation is O(log nj so whatever we use it must O(log n) or better. Lets use the rule if the height of the subtree are equal we go left else we go right. In our exemple, we go all the way left and insert then percolate and ajust the height of each father node. The seconde element we add goes to the right first because the 2 subtree have unequal heights the left all the way down insert then percolate and ajust the height of each father node. Imagining that the root is at position 0 the insertion order is 7, 11, 9, 8, 10 and the this rule breaks because it would add a node on level 5 while level 4 is not full. I tried to think of a way to obtain the order … (i will come back, i have to work)

    • @dominiquefortin5345
      @dominiquefortin5345 6 หลายเดือนก่อน +1

      @@MohammedAli-p7e9d Let me correct myself. IT is not wrong just inefficient. He has to keep 2 counts in each node, one for of all the nodes in the left subtree and one for of all the nodes in the right subtree. There is a better way. By using the total element count plus one and from the most significant bit to the least, from the root, go left on a 0 and go right on a 1.

  • @supersakib62
    @supersakib62 ปีที่แล้ว

    Excellent explanation

    • @brendawilliams8062
      @brendawilliams8062 ปีที่แล้ว

      I t seems so. I just came in to explore number theory. 💕 the good teachers in different fields.

  • @jimmycheong7970
    @jimmycheong7970 2 ปีที่แล้ว

    Amazing video. Thank you!

  • @utkarshaggarwal1631
    @utkarshaggarwal1631 4 ปีที่แล้ว

    Amazing explanation. thanks

  • @maxsuelfernandes3016
    @maxsuelfernandes3016 3 ปีที่แล้ว

    Such an amazing video, thanks

  • @RV-kl2wl
    @RV-kl2wl 2 ปีที่แล้ว

    Just 1 mins and 40 sec into this video and already liked and subbed.

  • @benzeltser9851
    @benzeltser9851 3 ปีที่แล้ว

    THIS IS MORE THAN GREAT THIS IS INCREDIBLE

  • @ArshdeepSingh-rh3zb
    @ArshdeepSingh-rh3zb 4 ปีที่แล้ว

    Great Explaination thanks

  • @polarbeargc7491
    @polarbeargc7491 4 ปีที่แล้ว

    Great animation! Learned a lot.

  • @Karan-ms5es
    @Karan-ms5es 3 ปีที่แล้ว +1

    Could you make a video on TRIE ?

  • @avocode1487
    @avocode1487 2 ปีที่แล้ว +1

    Please make video on radix Heap, as It is difficult to understand. Thanks for this awesome video 👍👍

  • @alexeydulin8587
    @alexeydulin8587 2 ปีที่แล้ว

    Really nice explanation, so thank you so much.

    • @dominiquefortin5345
      @dominiquefortin5345 8 หลายเดือนก่อน +1

      Except the information in this video is just so slightly wrong, that people will not know it is bad. So no, not nice

  • @AmirAli-hg9bk
    @AmirAli-hg9bk 2 หลายเดือนก่อน

    great video, thank you

  • @Aditya-on6ps
    @Aditya-on6ps 4 ปีที่แล้ว +1

    keep the good work sir

  • @rajdave7357
    @rajdave7357 4 ปีที่แล้ว

    My god, you are so amazing please make more videos, we need you

  • @leomysky
    @leomysky หลายเดือนก่อน

    Thanks for the video

  • @aidynabirov7728
    @aidynabirov7728 3 ปีที่แล้ว

    Great explanation!

    • @aidynabirov5932
      @aidynabirov5932 8 หลายเดือนก่อน

      @@dominiquefortin5345then tell me the right one?

  • @anjaliasolkar8821
    @anjaliasolkar8821 4 ปีที่แล้ว +2

    Amazing💯

  • @tarnum113
    @tarnum113 3 ปีที่แล้ว

    Thanks Brian!

    • @tarnum113
      @tarnum113 8 หลายเดือนก่อน

      @@dominiquefortin5345 doesn’t matter. The man is a legend

  • @neuplop
    @neuplop ปีที่แล้ว +1

    But if you want to search for one specific in the bottom of the list you don't know where it is.

  • @brian_kirk
    @brian_kirk 3 ปีที่แล้ว +1

    Excellent video, nice job. Is insertion left-child first or left-most-leaf first? Left-most-leaf would be consistent with array visualization of heaps?

    • @dominiquefortin5345
      @dominiquefortin5345 8 หลายเดือนก่อน +1

      Insertion should be donne at the end of the array, no left-child or right-child.

  • @marwahmaher8574
    @marwahmaher8574 4 ปีที่แล้ว

    thank you, it was helpful

  • @dipakpardeshi6618
    @dipakpardeshi6618 11 หลายเดือนก่อน +3

    at 4:30 in video, you have shown wrong complete binary tree, stop teaching wrong concepts.

  • @derrylmartinez8010
    @derrylmartinez8010 3 ปีที่แล้ว +1

    thank you so much

  • @jibachhyadav7241
    @jibachhyadav7241 4 ปีที่แล้ว +1

    Please do cover more portion of ds and algo. Lots of Love. Thank You

    • @SpanningTree
      @SpanningTree  4 ปีที่แล้ว +2

      Feel free to suggest any data structures and algorithms you'd like to see covered!

  • @audunoklevik4435
    @audunoklevik4435 2 ปีที่แล้ว

    Good explanation

    • @dominiquefortin5345
      @dominiquefortin5345 8 หลายเดือนก่อน

      Except the information in this video is just so slightly wrong, that people will not know it is bad. So no, it is not good

  • @leelee3423
    @leelee3423 2 ปีที่แล้ว

    well explanation !

    • @dominiquefortin5345
      @dominiquefortin5345 8 หลายเดือนก่อน +1

      Except the information in this video is just so slightly wrong, that people will not know it is bad.

  • @nazli9457
    @nazli9457 ปีที่แล้ว

    very helpful!

  • @jamesmejia2955
    @jamesmejia2955 ปีที่แล้ว

    Great vid, on an unrelated note, you sound just like the dude from CS50 course

  • @toolazy5899
    @toolazy5899 ปีที่แล้ว

    thanks dude!

  • @stone_pilot
    @stone_pilot 3 ปีที่แล้ว

    I think it would have been more helpful if you were more specific when discussing time complexity, but I still found this video useful

  • @snozking
    @snozking ปีที่แล้ว

    how would you code something like this?

  • @VirtuelleWeltenMitKhan
    @VirtuelleWeltenMitKhan ปีที่แล้ว

    nice video :D
    at first I thought this is just a binary tree

    • @dominiquefortin5345
      @dominiquefortin5345 8 หลายเดือนก่อน +1

      It is a binary tree, it is a balanced binary tree. It is not a binary search tree.

    • @VirtuelleWeltenMitKhan
      @VirtuelleWeltenMitKhan 8 หลายเดือนก่อน

      @@dominiquefortin5345 at first I thought this is just a binary tree

  • @udic01
    @udic01 ปีที่แล้ว

    What is the complexity of searching an element?

  • @mooyee1982
    @mooyee1982 3 ปีที่แล้ว

    讲得不错!!

  • @minecameraPL
    @minecameraPL 4 ปีที่แล้ว

    Thank you

  • @enishalilaj9309
    @enishalilaj9309 3 ปีที่แล้ว +3

    The explanation is quite good, but there are some small mistakes such as insertation and when you said the child cannot be smaller than the parent in Binary Heaps, that all depends if the Binary Heap is Min or Max, so that rule only exists when we define the Binary Heap!! Great vid!

    • @s0ulweaver
      @s0ulweaver ปีที่แล้ว +2

      He did say that we will be talking about min-heap for this explanation

  • @klausbdl
    @klausbdl ปีที่แล้ว

    It would be cool to show how that would work in python or some other language

  • @PraiseTheSquid
    @PraiseTheSquid ปีที่แล้ว

    You made this fucking easy, thank god.

  • @messapatingy
    @messapatingy หลายเดือนก่อน

    oops "2:99 Insertion" - 3:01 is the time

  • @عبداللهاسماعيل-ذ9و
    @عبداللهاسماعيل-ذ9و 4 ปีที่แล้ว +1

    thanks

  • @TheSwissGabber
    @TheSwissGabber ปีที่แล้ว

    would have been nice to show how this is better then a linked list.

  • @AnasKhan-pb8tn
    @AnasKhan-pb8tn 3 ปีที่แล้ว +5

    Binary heap should be a complete binary tree , that means left to right. The insertion is wrong.

  • @wailelbani9815
    @wailelbani9815 2 ปีที่แล้ว +3

    the insertion is wrong

  • @Matthew54861
    @Matthew54861 4 ปีที่แล้ว

    Just a heads up, your timestamp for Insertion is not valid!

  • @FranzBiscuit
    @FranzBiscuit ปีที่แล้ว

    So basically a Huffman tree. Which of course could be implemented as an array (albeit, at the expense of performance).

    • @dominiquefortin5345
      @dominiquefortin5345 8 หลายเดือนก่อน +1

      No, not a Huffman tree, a balanced binary tree. "... at the expense of performance ..." I don't think you know what you are talking about. You are comparing apples to oranges.

    • @FranzBiscuit
      @FranzBiscuit 8 หลายเดือนก่อน

      @@dominiquefortin5345 Yeah I honestly don't know what I was thinking there. I may have answered that one before I had my coffee! Cheers....

  • @aarMess
    @aarMess 3 ปีที่แล้ว

    Good work! Btw. consider investing in a microphone, its worth it...

  • @powerdust015lastname4
    @powerdust015lastname4 ปีที่แล้ว

    6:44 why take a low priority element? you could just skip this step and swap the smallest children with null instead

    • @vr77323
      @vr77323 ปีที่แล้ว +1

      Could you elaborate on that? I don't think I understand what you mean by setting smallest children to null

    • @powerdust015lastname4
      @powerdust015lastname4 ปีที่แล้ว

      @@vr77323 In the graph at 6:44 the root element is null.
      So we could just swap it with the smallest of its children and repeat, making the first step (setting 11 to be the new root) obsolete.
      In the animation it would look like the value null is propagating downwards, kinda like air bubbles in water (but upside down) or the gap between cars in a traffic jam.

    • @dominiquefortin5345
      @dominiquefortin5345 8 หลายเดือนก่อน +1

      @@powerdust015lastname4 What you propose is equivalent. If after that you move the 11 in the hole and you move the 11 toward the root until the parent is smaller.

  • @kakol20908
    @kakol20908 2 หลายเดือนก่อน

    This video is overcomplicating binary heap.
    Watch Sebastian Lague's Heap Optimization video in his A* Pathfinding series.
    The way he explains makes more intuitive sense.

  • @عبداللهاسماعيل-ذ9و
    @عبداللهاسماعيل-ذ9و 4 ปีที่แล้ว +2

    keep more in algorithm

  • @mossthebryophyter
    @mossthebryophyter 3 ปีที่แล้ว

    Why is it that videos on TH-cam explain stuff better while I'm paying a ridiculous amount of money just to attend a school?

  • @BelegaerTheGreat
    @BelegaerTheGreat 6 หลายเดือนก่อน +3

    I don't like this. Just add nodes by layers.

  • @alejandrojara7303
    @alejandrojara7303 8 หลายเดือนก่อน

    Brian is that you? I'd recognise that voice from a mile away

  • @JoeyCarb
    @JoeyCarb ปีที่แล้ว

    I'm a middle child. Always left out and forgotten.

  • @jaimetagle8876
    @jaimetagle8876 3 ปีที่แล้ว

    this will be thanos favorite data structure..