B-trees in 6 minutes - Deletions

Поділитися
Вставка
  • Опубліковано 27 січ 2025

КОМЕНТАРІ • 53

  • @flower77769
    @flower77769 2 роки тому +44

    Don't get discouraged. Please keep uploading these!

  • @MT-oo8sx
    @MT-oo8sx 2 роки тому +16

    Your B tree and red black tree video I think are the best that I can find on UA-cam. Please keep uploading these video. I like your teaching a lot.

    • @MichaelSambol
      @MichaelSambol  2 роки тому +4

      Thank you! More coming. Hope the audio was OK, I had some issues in there. I appreciate you watching!

    • @MT-oo8sx
      @MT-oo8sx 2 роки тому +1

      @@MichaelSambol The audio is very clear but I think louder a little bit will be great!

    • @MichaelSambol
      @MichaelSambol  2 роки тому +2

      Cool, will make adjustments!

  • @murathankayhan1494
    @murathankayhan1494 Рік тому +5

    I watched your whole playlist for B-Trees. They are very helpful. Good job Michael! Wish me good luck for my data management exam on tomorrrow :)

  • @vteckickedin2365
    @vteckickedin2365 8 місяців тому +1

    Excellent vids on b trees, you've come in clutch for pretty much my entire CS degree now haha, from first year all the way to my final now. Appreciate it a tonne. Just one important thing about this algorithm to note to most people reading (I believe it wasn't mentioned in the video but I may be wrong & too lazy to check lol): deletion can only happen with a case 1, every other case really just sets up the b tree in a "neater" format and recursively calls delete until a case 1 is invoked and the desired element can be deleted. Another thing that took me some time to realise - for case 2a and 2b -> you do not replace with simply the left/right most element of the righ/left child but you must traverse and actually find the immediate predecessor/successor to the element you're trying to delete. Anyways, best of luck to everyone on their DSA journeys

  • @amanbisht579
    @amanbisht579 2 роки тому +54

    in the case 3b can't we just directly delete 17 as it won't break any of the properties of b tree??

    • @EckiSchmecki
      @EckiSchmecki Рік тому +7

      yes, but he decreased the height of the tree while deleting 17, improving the tree over all.
      this was not possible before, because the leaf with 17 in it was bigger (size 4) than 2t-1 (size 3) for a tree with t=2

    • @antrikshkumar668
      @antrikshkumar668 Рік тому

      It is essentially done to decrease steps in the future because we don't really know how many keys there will be before we reach that node(if that has 2 then we will have to do the same operation but making it much more complicated, travelling down a tree is much easier than to go up

  • @sanjaykg10
    @sanjaykg10 2 роки тому +6

    The legend and saviour is back 😇

  • @aramh3376
    @aramh3376 8 місяців тому

    thank you MIchael, watched all the playlist, good teaching

  • @adeven2226
    @adeven2226 2 місяці тому +1

    4:09 why can't we just delete 17 from the leaf? After the deletion keys amount in this node will equal to 3 (which is equal to t)

  • @DeltaNachos
    @DeltaNachos 2 роки тому +1

    Was looking for review before my final tomorrow, this clears up everything! Thank you!

    • @Learn-jz1sc
      @Learn-jz1sc Рік тому

      How’d it go?

    • @DeltaNachos
      @DeltaNachos Рік тому +1

      @@Learn-jz1sc There was only 1 question on B trees lmao, otherwise well

  • @adeven2226
    @adeven2226 2 місяці тому

    4:37 what if root had more than one key? would we still move only one key from the root, or all of them?

  • @RishikeshKasireddy
    @RishikeshKasireddy 3 місяці тому

    in case 3b how are you sure that if u merge it wont violate upper bound property cause there maybe 2 or 3 keys in root right?
    Please Clarify

  • @mizit8864
    @mizit8864 8 місяців тому +1

    why do we care about root in 3b ? explain someone pls

    • @mizit8864
      @mizit8864 8 місяців тому

      ahaa, cuz we would have 6 siblings, but only 4 keys, so it means we have to have 5 keys

  • @ArkadeepMukherjee-x5h
    @ArkadeepMukherjee-x5h 2 місяці тому

    Great video❤

  • @akam9919
    @akam9919 Рік тому +7

    I don't get why we care about the parent in the recursion path in 3b. Wouldn't the tree still be perfectly valid?

    • @mizit8864
      @mizit8864 8 місяців тому

      we would have 6 siblings, but only 4 keys, so it means we have to have 5 keys

    • @ojaskulkarni8138
      @ojaskulkarni8138 2 місяці тому +1

      ​@@mizit8864why so?

  • @omerfaruk4579
    @omerfaruk4579 8 місяців тому +1

    thank u Thad Castle

  • @happywhale1786
    @happywhale1786 2 роки тому +1

    Thank you, your code is so clean and clear! Yet, I'm still not clever enough to understand all...

    • @MichaelSambol
      @MichaelSambol  2 роки тому

      Which part do you have questions on and how can I help ? 🙂

    • @Learn-jz1sc
      @Learn-jz1sc Рік тому

      2:20 Bookmark

  • @rodituclashroyale1812
    @rodituclashroyale1812 2 роки тому +1

    do we check this recursive if keys = min_keys for the root node as well? because technically there is nothing to shift, so nothing would change? Also what if that node we need to shift into is even deeper, do we shift then all the siblings' keys and every key in every node that's above? And If resulting node has too many keys we just do median and move up until the property is satisfied?

  • @devansh_4u
    @devansh_4u 2 роки тому +1

    Why and what did we do in case 3B? I mean I don't understand the need to merge the two nodes! please help !!!!

    • @MichaelSambol
      @MichaelSambol  2 роки тому +3

      We made the assumption in the beginning that we only call delete on a node with t keys. The delete method is recursive and starts at the root. On our way down to delete key 17, we encountered a node with t-1 keys, hence the need for case 3B.

    • @AdapG
      @AdapG Рік тому +3

      @@MichaelSambol The node has four keys and the t = 3 so 3-1 = 2 no?

  • @myrlla_
    @myrlla_ 22 години тому

    God bless you

  • @atharvameher5880
    @atharvameher5880 Рік тому

    t=m/2
    where maximum nodes can be m-1
    So for m=5 max nodes 4 and min nodes=t=2

  • @Maxerom24
    @Maxerom24 11 місяців тому

    Great video. It would have been great if you can visualize the code functions line by line. Nevertheless, This video is great.

  • @amjafdamer3960
    @amjafdamer3960 2 місяці тому

    can someone explain 3b stage

  • @mostafanasr913
    @mostafanasr913 2 роки тому

    May you explain graphs? 🙏

  • @gilesbbb
    @gilesbbb Рік тому

    What happened to the reverb? It gave you a ton of gravitas! (Thanks for the great videos btw).

    • @MichaelSambol
      @MichaelSambol  Рік тому +1

      I moved and had some audio issues 🤦🏻‍♂️
      Thank you!

  • @flosset6070
    @flosset6070 Рік тому

    what does t stands for :/ ?

    • @MichaelSambol
      @MichaelSambol  Рік тому

      Go back a few vids in the playlist, I explain it in the intro video

  • @SanAleksiusII
    @SanAleksiusII 2 роки тому

    good video

  • @zerosypher0114
    @zerosypher0114 2 роки тому +2

    The series is over tho :(

  • @kalyansathvik8009
    @kalyansathvik8009 11 місяців тому

    binomial trees and heaps also please

    • @MichaelSambol
      @MichaelSambol  9 місяців тому

      Here's my plalist on heaps: ua-cam.com/play/PL9xmBV_5YoZNsyqgPW-DNwUeT8F8uhWc6.html

  • @energy-tunes
    @energy-tunes 6 місяців тому

    you just know shit like this takes 2k loc to implement efficiently when even high level explanation isnt trivial

    • @MichaelSambol
      @MichaelSambol  6 місяців тому

      github.com/msambol/dsa/blob/master/trees/b_tree.py 312 loc ;)

  • @khalifacastaway6356
    @khalifacastaway6356 2 роки тому +2

    Hard

  • @MarkusKofler
    @MarkusKofler 8 місяців тому

    Slight formal error at 3a: it should be 2*(t-1) not 2t-1