AVL tree removals

Поделиться
HTML-код
  • Опубликовано: 19 окт 2024

Комментарии • 35

  • @phoneix24886
    @phoneix24886 5 лет назад +16

    William. This is undoubtedly the simplest and the most authentic explanation of an AVL tree node deletion and I could show it to my brother. It helped him a lot. Thanks to you.

  • @vivekkadyan6330
    @vivekkadyan6330 6 лет назад +8

    Sir you are a lifesaver. Just before my exam I am able to clear my doubts just because of you.

  • @daveamiana778
    @daveamiana778 3 года назад +3

    very insightful, I love the format of this content, very straightforward and concise, saved me a lot of time.

  • @joseville
    @joseville 2 года назад +5

    5:44 the largest value in the left subtree is usually called the predecessor

  • @СергейСоловьев-ъ8с
    @СергейСоловьев-ъ8с 3 года назад +7

    4:29 is not an AVL tree, because balance factor of 9 is -2 (left subtree is greatrer)

    • @alexz4006
      @alexz4006 3 года назад +3

      Correct, Im not sure why he didn’t mention balance, since its the primary property of AVL trees lol

    • @kamleshkumarsahu9597
      @kamleshkumarsahu9597 Год назад

      I was also wondering that

  • @szerednik.laszlo
    @szerednik.laszlo 3 года назад +4

    Watched it on 2x speed, thanks for summarizing in 5 mins the lecture what my university couldnt explain in 45 mins.

    • @TranscendentPhoenix
      @TranscendentPhoenix 3 года назад +3

      You and every other genius on youtube watches it at 2x speed and then complains when they get 50 on the exam.

  • @terrytai5193
    @terrytai5193 5 лет назад +4

    This video helpd me pass my final exam.Thanks lot!

  • @alaazamel8176
    @alaazamel8176 3 года назад +1

    Thank you So much for this explanation, you are so underrated ❤❤

  • @T3hIluvatar
    @T3hIluvatar 5 лет назад +4

    Isn't what you call "left tree successor" called predecessor? I'm not sure if I understand it right, but I though that successor of node N was the node with the smallest key in the right subtree, and predecessor was the largest node in the left subtree

  • @anwarulbashirshuaib5673
    @anwarulbashirshuaib5673 3 года назад +3

    How did you create these amazing slides, especially those BSTs and step-by-step explanations of the algorithms? I would like to create for myself

  • @Diego01201
    @Diego01201 6 лет назад +2

    High quality video! Really helped me. Thanks in advance.

  • @ruchirsharma5723
    @ruchirsharma5723 3 года назад +1

    Amazing explanation!!

  • @sephycai
    @sephycai 5 лет назад +2

    At 7:52. Which node do you use on the rebalancing when you rebalance the tree? Is it the new root of the tree which is the new "11"?

  • @plontulublalulu
    @plontulublalulu Год назад

    In the case of a normal BST, couldn’t you just do the two subtrees case for one subtree?

  • @sonigoku
    @sonigoku 5 лет назад

    Thanks For the easy explaining what professor made it hard to understand

  • @nyahhbinghi
    @nyahhbinghi Год назад

    How does AVL balancing different from red-black balancing?

  • @gytisx13
    @gytisx13 5 лет назад +1

    What if I want to remove node 3 then node 1 from tree shown at 7:44? There needs to be some kind of rebalancing, that seems hardest for me. Because that brach will have a height difference of 2.

  • @varshu8296
    @varshu8296 Год назад

    thank you! :)

  • @Oingoboingo710
    @Oingoboingo710 5 лет назад +2

    so underrated♥

  • @darkseeven
    @darkseeven 5 лет назад +2

    9 minutes > my teacher 6 hours

  • @abdulahadsheikh3366
    @abdulahadsheikh3366 4 года назад +1

    Quality video.

  • @francodominguez9139
    @francodominguez9139 10 месяцев назад

    but the tree isn't even balanced initially?

  • @cosmeticspk1508
    @cosmeticspk1508 5 лет назад +11

    it's not
    avl

    • @WilliamFiset-videos
      @WilliamFiset-videos  5 лет назад +5

      Please see the description for the previous videos explaining the update and balance methods. Otherwise removing from an AVL tree is identical to removing from a BST. Please check out the next video (source code video) if you are still struggling to piece together how removals work. Hope this helps!

  • @hizircanbayram9898
    @hizircanbayram9898 6 лет назад +2

    Keep it up!

  • @isunktheship
    @isunktheship 5 лет назад

    Question.. you call delete on 8, the code recurses through the tree until it finds the element with value "8", which sets up this video.
    Next you recurse from node 8 to determine a valid replacement (if any). This is determined to be 11 as it's the smallest element on the right side.
    From here you simply assign the value of the "smallest element" to the "element being replaced", that's easy, 8 becomes 11.
    At 7:19 you say we need to recurse through the tree one more time to remove the 11, but I don't believe this step is necessary. 11 is already determined to have no left-children, and you have it's location in memory. So wouldn't you simply do this..
    nodeToDelete = find(8); // address of node in question
    nodeToReplace = nodeToDelete.findReplacement(); // address of replacement node
    // ~~some logic here to handle no replacements being found, e.g. node being replaced has no children ~~
    nodeToDelete.value = nodeToReplace.value; // assign the value of the replacement node to the found node
    nodeToReplace.right.parent = nodeToReplace.parent // point the replacement RIGHT to the replacement PARENT
    nodeToReplace.parent.left = nodeToReplace.right // point the replacement PARENT to the replacement RIGHT
    free(nodeToReplace); // free up memory of the moved node
    If node(11) is already in memory I don't see a reason to recursively find it again

  • @sarthakshah1058
    @sarthakshah1058 6 лет назад

    This deserves more views

  • @specspec6851
    @specspec6851 3 месяца назад

    4:50 how is the predessecor is 7? it should be 8

  • @GaLaVrAmOv
    @GaLaVrAmOv 5 лет назад +4

    That's not right bro, 4:55 in this case, 9 have to be removed and replaced with 8, then rotate LL from 8, because of 8 is bigger than 7 so it'll still be an avl binary tree

    • @victorxu9634
      @victorxu9634 3 года назад

      The example in the video satisfied the BST invariant. So it is correct. BSTs does not need to have unique solutions. Since it is balanced, no further action is needed even if its an AVL tree.

  • @Bryan-bh7cy
    @Bryan-bh7cy 3 года назад

    the last implementation of AVL tree is slow...