Red-black trees in 3 minutes - Rotations

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

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

  • @DVZM.
    @DVZM. 5 ปีที่แล้ว +84

    It is very sad that you stopped making those amazing videos...

  • @andrewmartin4045
    @andrewmartin4045 7 ปีที่แล้ว +46

    I love the conciseness of these videos, Michael! Keep up the great work! One recommendation I have is to make the pseudocode you provide more approachable by re-labeling the variables to match your diagrams.

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

      Very good suggestion, thank you!

  • @leo6d985
    @leo6d985 4 ปีที่แล้ว +6

    You didn't get enough credit for these, they are appreciated it.

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

    Michael, this is a great playlist on Red-black trees. However, for the rotation video, I'd give an example that accomplishes the goal of decreasing the height of the tree. Your example was fine in demonstrating rotation, but did not help with balancing. Please keep up the high quality teaching. You are a great help to many people.

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

      'cz balancing aspect of rotation in R-B Tree becomes apparent only with insertion deletion etc.
      u dont just rotate on whim in rb-tree to balance.

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

    I've read elsewhere that the maximum height of a red-black tree is 2 * log(n + 1). This is not to say that this isn't a fantastic series of videos, because it is and they've helped me substantially! Thank you for that!

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

      The height of a Red-Black tree is always O(Logn) where n is the number of nodes in the tree. 2* log(n+1) is still O(Logn)

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

      To be exact(if anyone is confused), in CS when we count the big O(worst case), we only care about the most influential term and take away its coefficient. Therefore the 2 & 1 in 2 * log(n + 1) should both be omitted, and you get O(log n).

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

      @@KennyChowPD I might be wrong but it's for space or time complexity I think whereas we study the relation between the height of a tree and element count here.

  • @piyushnariani09
    @piyushnariani09 7 ปีที่แล้ว +79

    Please post the video of Red-Black Tree Deletion as well

  • @AnonymousDeveloper1
    @AnonymousDeveloper1 7 ปีที่แล้ว +4

    You make great videos about algorithms. Please keep it up and produce more videos like that! Short, easy and very helpful.

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

    Your videos are awesome! Straight to the point and short compared to the others on youtube.

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

    One of the best Videos yet, understood everything perfectly😊

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

    Congrats Michael and thanks, your videos are amazing. I wish my college professor were as good as you.

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

      Hah, its almost like they're getting paid by your university which you pay tuition to go to...

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

    Thank you for you picture illustration. It's super clear!!!!

  • @Randeesha
    @Randeesha 5 ปีที่แล้ว

    superb explanation within 3.04 mins.. wow... good luck...

  • @Gary-lh4fg
    @Gary-lh4fg 7 ปีที่แล้ว

    Very clear, methodical and intuitive

  • @PL_chochlikman
    @PL_chochlikman 7 ปีที่แล้ว

    in few years if you will hold this level of video's you;ll be number one youtuber of informatics xD

    • @DVZM.
      @DVZM. 5 ปีที่แล้ว +1

      yeah he stopped immediatelly...

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

    Useful, thanks so much, I was confused on rotating but it's actually simple

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

    Bro thank you the explanation was so good you saved me👍👍

  • @merinkjacob2443
    @merinkjacob2443 6 ปีที่แล้ว

    Dear Michael, Thank you very much for this video. You are my saviour :)

  • @terigopula
    @terigopula 6 ปีที่แล้ว

    Crisp, concise and clear.

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

    The other important fixup for Red-black trees is recolouring.
    A combination of recolouring and rotation is done on inserts & deletes to fixup red-black tree violations.
    Fixups go in the direction of the root node.
    For Insert, a maximum of 2 rotations are required.
    For Delete, a maximum of 3 rotations are required.

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

    I wish it was explained like that in data structure lectures. :D

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

    By doing a rotation we are simulating the right order of inserting node

  • @12husnainabbas
    @12husnainabbas 7 ปีที่แล้ว +2

    your videos are very helpful, keep up the good work!!

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

    2:23 i knew right away on seeing this that it is Cormen Intro to DAA

  • @StreamerSagaYT
    @StreamerSagaYT 6 ปีที่แล้ว +185

    Exams in next 10 min .... Huh.

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

    Amazing explanations. Thanks

  • @akshatjain7797
    @akshatjain7797 5 ปีที่แล้ว

    Really helpfull ....please make more videos on algorithms and analysis

  • @bassilorabii7183
    @bassilorabii7183 6 ปีที่แล้ว

    Very Helpful and quick !

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

    awesome video, thanks man

  • @sdshsjg
    @sdshsjg 8 ปีที่แล้ว

    best guide ever

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

    so if I understand and did it correctly, is the solution to the the tree shown at 0:22 this?
    12
    / \
    8 15
    /\ / \
    5 9 13 23
    /-(red)
    19

  • @ambatirakesh5597
    @ambatirakesh5597 7 ปีที่แล้ว

    Please make videos on design and and analysis of algorithms

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

    Hi Michael..can you do a video on Big O notation? I like your explanations on these CS topics!

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

    thank you so much, this was extremely helpful for my first implementation, the psuedocode helped my understanding greatly!

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

    ok, i can understand why you rotated the 10, 5, 2 and the 12 since they're all connected. But why did you flip 8 to the other side of the tree?? No explanation. Just confused. Even if you keep the 8 on the same side in either rotation instead of changing it to the other side, it would still be balanced.

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

      4 years ago but incase anyone reading now wonder the same:
      the 8 starts off as the left-child of 10, but after the rotation the left-child of 10 is now 5 instead
      a node cannot have 2 left children, so we must now store 8 somewhere else.
      luckily, since 10 was originally 5's right-child, it means that that 5's right-child spot is now free, since 10 is 5's parent now instead.
      therefore we can store 8 as 5's right-child
      it still conforms to the structure of binary tree structure since 8 was originally on the right sub-tree of 5, and we know all elements of that right-subtree must be greater than 5, so it therefore applies that 8 can go to the right of 5.
      ALSO, since 8 was originally the left -child of 10 (to the left of 10), we know it must go somewhere on the left subtree of 10, which ends up as the subtree with 5 as the top node.

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

    ummm, you should have said whether right rotation is just mirror of left rotation? seems like answer is yes? maybe add annotations after the fact? that would be beautiful. Also, I don't know when to call leftRotate(x) or rightRotate(y), what is the context? appropriate conditon for which to make those calls?

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

      Yeah, it's just a mirror. Check out the other videos in the playlist on when you use rotations (i.e., when you insert and delete so the tree keeps RB properties). Also the code in my GitHub shows them in action.

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

    just a question ...the concept of rotations is the same also for an avl right ? the left and right rotations.

    • @iustinnegrea3869
      @iustinnegrea3869 8 วันที่ผ่านมา

      I have seen Something for the avl where the rotations were keeping the trece ballannced, but here it is not

  • @任安明
    @任安明 7 ปีที่แล้ว

    i like it so much。 thank you

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

    Hello sir, is there a video for red black deletion?
    and the videos are amazing. tysm :)

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

    This is Fireship if he taught Data Structures !

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

    where. is video for deletion

    • @dennistu
      @dennistu 6 ปีที่แล้ว

      it was deleted

    • @DVZM.
      @DVZM. 5 ปีที่แล้ว

      @@dennistu hhahaha

  • @user-sx5ib8vd6l
    @user-sx5ib8vd6l 21 วันที่ผ่านมา

    bro is W

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

    Too short, should have explained node by node or at least stated general rules first.

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

    nice name

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

    Exam in 2 minutes

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

    Deletion!! Lol

  • @FanaticBall
    @FanaticBall 6 ปีที่แล้ว +4

    To be honest you explain next to nothing, you just move the nodes around and read what a simple textbook says. Liked your other videos, you failed here.

  • @asadullahrafiq-em1pz
    @asadullahrafiq-em1pz 29 วันที่ผ่านมา

    these sesseion are for indian not foreigeiner

  • @AryanSingh2512.
    @AryanSingh2512. 6 ปีที่แล้ว +1

    please skip this video.

  • @gomes8335
    @gomes8335 6 ปีที่แล้ว +4

    Where is the deletion video mate?