Binary Search Tree - Deletion

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

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

  • @ongxa888
    @ongxa888 2 года назад +10

    case 3 is not correct, if 6 has 2 child (left, right), for example, 5.9 and 6.1. the right way is to find min value of right tree (5.9), replace it with deleted node (replace 5 with 5.9), then call recursive to delete min value (5.9) on right tree (which is back to case 2)

    • @helloworldcsofficial
      @helloworldcsofficial 5 месяцев назад

      That was my understanding too. Replace the node with its in-order successor (the minimum value node in its right subtree)

  • @codewithkolhar3131
    @codewithkolhar3131 4 года назад +3

    Your videos are really easy to understand. Hats off. I build of Binary tree and implemented all operations on my own. Thanks

  • @sunnythegreat9617
    @sunnythegreat9617 3 года назад +7

    What if, when deleting 5 and replacing it with 6, if the node 6 also had children, what do we do?

    • @thisurathenuka8362
      @thisurathenuka8362 2 года назад +1

      We are replacing with the inorder successor. Inorder successor usually is a leaf node when it comes to deletion

  • @_paulacr
    @_paulacr 2 года назад +2

    Hello Lalitha, I loved your explanation about deletion, for sure was the best video for me to understand that. Thank you for posting that :)

  • @kevinegal7886
    @kevinegal7886 3 года назад +6

    Nice explanation!
    Before watching, I was always unsure, rather it is necessary to delete the data inside the node, which we want to delete... But as it seems it is enough, when we just remove the pointer/reference to the node, which we want to delete.(For example in case 1)
    As the garbage collector will do the rest.

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

      What if you are using c/c++ or performance is crucial?

    • @MrNukenin16
      @MrNukenin16 2 года назад +1

      @@georgiilkov9915 THEN YOU CRY

    • @georgiilkov9915
      @georgiilkov9915 2 года назад +1

      @@MrNukenin16 or learn memory management

  • @nocturnal-chou
    @nocturnal-chou 2 года назад +4

    Thank you for the clear, and simple explanation! Seems like most tutorials cannot explain it this easily.

  • @theekshani1237
    @theekshani1237 2 года назад +1

    Thank you very much madam. It is very good to explain your lesson & I like your explanation ❤️

  • @mohammadahmedragab837
    @mohammadahmedragab837 3 года назад +2

    thank you so much for your amazing helpful simple easy explanation, please keem. making these videos ❤️

  • @ZuhaaFatima-gw7mj
    @ZuhaaFatima-gw7mj 18 часов назад

    omg thank you sooooooooooooooooooo much you're a life savour

  • @AviPars
    @AviPars 2 года назад +1

    What about duplicates ?

  • @kristof910k
    @kristof910k 4 года назад +3

    Thanks for the video! I screenshotted this!

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

    Thanks for your knowledge based class mam

  • @cantcode023
    @cantcode023 2 года назад

    what is an inorder traversal?

  • @r4jivaim
    @r4jivaim 2 года назад +1

    very concise and clear, thank you

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

    Mam case 3 is not right LEFT MOST ELEMENT IN RIGHT SUBTREE REVIEW IT PLZ

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

    Thank you very much, I like your explanation

  • @gulshanrajput2458
    @gulshanrajput2458 2 года назад

    Every things are so good... Thanxx

  • @raina8946
    @raina8946 2 года назад

    Good explanation...

  • @paulr5111
    @paulr5111 3 года назад +2

    What if the 6 in case 3 already has 2 children?

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

      I wondered the same thing.

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

      inorder successor will become the right child of 6 and replace it with 5

  • @Pc_talk
    @Pc_talk 2 года назад

    Mam why you replace 6

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

    You makes everything easy thank you so much ma'am

  • @czyzycki95
    @czyzycki95 11 месяцев назад

    grate video :D

  • @Pc_talk
    @Pc_talk 2 года назад

    Becouse in binary search tree right side last node is greater than

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

    THANK YOU!! my textbook makes it sound so confusing

  • @maryamzamzami7615
    @maryamzamzami7615 2 года назад

    Very clear thank u so much

  • @therandomactivist1124
    @therandomactivist1124 4 года назад

    what if you remove 3?

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

      In case you meant the last tree drawn, you get 3's successor, which is 4. We know that 4 has no left child (otherwise, 4 wouldn't be the successor, which is a contradiction). Replace 3 with 4, and the right child of 3 will be the right child of 4. The left child of 3 will also be the left child of 4. Thus, we maintained the binary search tree property.

  • @hamshihamsu5461
    @hamshihamsu5461 2 года назад

    Thank you ❤️

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

    Please make a video in linked list insertion deletion

  • @nishanttomar7253
    @nishanttomar7253 4 года назад

    What if 6 has its two children. Then where the left child of 6 goes after performing deletion .

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

      If 6 has a left child then that child would be the inorder succesor, not 6.The inorder succesor of a node has no left child but it can have a right child

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

    inorder successor of 5 is 4 not 6!
    the inorder successor element of its right subtree!

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

    1000 thanks

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

    U r voice awesome maam....💞 and great explanation.......

  • @navaneetrao6935
    @navaneetrao6935 2 года назад

    good

  • @Pc_talk
    @Pc_talk 2 года назад

    You replace 4

  • @GuyKershtein
    @GuyKershtein 4 года назад

    Thank you so much!!

  • @nasirsoft5800
    @nasirsoft5800 4 года назад

    Superb

  • @vikaskumarjha1010
    @vikaskumarjha1010 4 года назад

    Hindi explanation of same problem - ruclips.net/video/XPGU8oFpJVA/видео.html

  • @NaveenReddy-is1cw
    @NaveenReddy-is1cw 4 года назад

    super mam.

  • @Pc_talk
    @Pc_talk 2 года назад +1

    This wrong answer

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

    what if 6 has children nodes?

    • @beastbeautybiker6656
      @beastbeautybiker6656 4 года назад

      The left child of 6 will become the right child of the left child of 6 and the right child of 6 will remain same.

    • @nishanttomar7253
      @nishanttomar7253 4 года назад

      @@beastbeautybiker6656 What is the algorithm for that case

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

    please help im under the water

  • @kamyagupta4030
    @kamyagupta4030 2 года назад

    Thank you so much!!!