Balanced binary search tree rotations

Поделиться
HTML-код
  • Опубликовано: 30 июл 2024
  • Learn about balanced binary search tree rotations
    Practicing for interviews? I have used, and recommend `Cracking the Coding Interview` which got me a job at Google. Link on Amazon: amzn.to/3cvMof5
    A lot of the content on this channel is inspired by the book `Competitive Programming` by Steven Halim which I frequently use as a resource and reference. Link on Amazon: amzn.to/3wC2nix
    ===========================
    Related videos:
    AVL tree intro: • Balanced binary search...
    AVL tree insertions: • AVL tree insertion
    AVL tree removals: • AVL tree removals
    AVL tree code: • AVL tree source code
    AVL tree source code:
    github.com/williamfiset/algor...

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

  • @qazaqwert
    @qazaqwert 3 года назад +125

    Why are free videos on the internet better than my college professors. Have a midterm on BST stuff tomorrow, this is a major help.

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

      hello connor6woop

    • @Zucr_
      @Zucr_ 2 года назад +17

      Because teaching is not the main profession of your professor. Their real job is to do research but they teach on the side. You can expect them to understand the material very well; however, you can't expect them to know how to convey that information very well even though you are probable paying up the ### to take their course.

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

    Extremely concise and clear! I was just asked how a self-balancing tree works and.. while I know how binary trees are built and function, I never learned about rotation and balancing.

  • @kaloyankraynin3944
    @kaloyankraynin3944 4 года назад +4

    Great video man, exactly what I needed! Helped me a ton :)

  • @Art-fn7ns
    @Art-fn7ns 5 лет назад +18

    That's by far superior to what my prof forced out of himself. Thanks!

  • @user-ej3iw8lw3w
    @user-ej3iw8lw3w 2 года назад +4

    A balanced binary tree, also referred to as a height-balanced binary tree, is defined as a binary tree in which the height of the left and right subtree of any node differ by no more than 1.

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

    I have a question: How to insert a new node to an existing balanced binary search tree (not an AVL tree)? Do I insert the new node normally like how I would with a binary search tree and then apply rotations? Or do I insert it into an array first, sort the array and then rebuild the balanced binary search tree?

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

    This is a top 5 educational video of all time

  • @randyn1080
    @randyn1080 9 месяцев назад

    Absolutely incredible. Thank you very much for your videos!

  • @pudisasikar7996
    @pudisasikar7996 4 года назад +5

    Dude... Ur Amazing visuals making damn easy... How come I found this late... I Bookedmarked urs... Awesome explanations..

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

    Thanks man really helped out.

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

    Thanks a lot from Brazil!

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

    a very good explanation, thank you 👏

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

    Thank you for this very helpful video!

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

    7:00 I think the code would be simpler by having methods that handle the double pointer update, i.e. methods `setLeft Child` and `setRightChild` which update the corresponding left/right pointer as well as the parent pointer, if any.

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

    Thanks for making man! Super helpful.

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

    Great video!
    3:13 I think it would have been best to label the nodes such that the inorder traversal is
    A, B, C, D, E

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

    To the point and clear explanation :) please note, the AVL tree intro: might not be the correct link. Thanks

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

    Considering the alphabetical order and the invariant as n.left < n and n < n.right; the BST shown in the videos does not satisfy the invariant condition.
    In the left tree we have N.left = B, n = A, and n.right = C. Now, B < A < C is not true. in the right tree: D < B < A < C is not true.

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

      exactly i don't understand this. did you figure out what he is trying to say?

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

    damn.. that's beautiful!!!!!!!!! Thank you so much!!!

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

    top 20 university and this video explained something i didnt understand for an hour in lecture in 8 mins

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

    Amazing video man love it

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

    What is the difference between remove and delete?

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

    3:31 defines BST as n.left < n and n > n.right. Now go to example at 4:25. Let's assume A = 4, B = 3, D = 1, and E =2. If when we rotate we make E the left child of A we follow the definition as to A, but we now fail the definition as to B because E < B even though E is in the right subtree of B. That would mean that if we searched the tree for the value 2 we would start at the root B with value 3 and go to the left subtree which would not lead us to E thus we would lose our O(log n). I am struggling to reconcile this.

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

      I see now that if B = 3 then E has to be >= 3 so it could not = 2.

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

      Thanks

  • @yomamasofat413
    @yomamasofat413 4 месяца назад

    3:31 does E have to necessarily be less than A? What if it is more?

  • @Jalalx
    @Jalalx 5 лет назад +6

    Two trees at 3:10 are a bit confusing! It would better if numbers were used instead of letters.

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

    Preparing to my amazon interview with your videos. Thanks!

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

    Thanks for the great explanations squeaky-voiced teen from Simpsons.
    Your explanations actually help a great deal and are more entertaining than my text books:)

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

    great explanation

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

    This is pure torture... :P Thanks though.. Got an exam tomorrow and this helped..

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

    Can some one tell me how is D < B? and how is A > C?

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

    This is AMAZIN !
    Way better than the crap served in MIT Open Courseware

  • @Victor-tl4dk
    @Victor-tl4dk 8 месяцев назад +1

    What is a "logarithmic height"?
    What is a "linear height?"
    Would it not be better to say a height based on linear proportions?
    I do not like meaningless language which this seems to be an example of. Pease feel free to explain :-). Maybe I'm not "getting it"

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

    Computer Scientists: "Let me introduce you to the secret high-art of informatics, young Padawan!"
    me: "Haha jQuery go brrrrrrrrt!"

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

    u saved me

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

    the goat

  • @WEARETHEDESCENDANTSOFGIGACHAD
    @WEARETHEDESCENDANTSOFGIGACHAD 5 дней назад

    My collage professor(he actually didn't deserve to br called a professor) did this topic it took him a whole hour long and in the what we got was lots of confusion

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

    Blanced Binary Search trees are cool

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

    Your website has an error !!! 503 Error .

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

    The DSW algorithm works well for balancing like this.

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

    I still don't understand lol

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

    u seem too surprised by elementary things. It's a bit annoying and distracting.
    Anyways, ok video. Helped me learn so thanks.