AVL 1 Introduction

แชร์
ฝัง
  • เผยแพร่เมื่อ 29 พ.ย. 2024

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

  • @fredericoamigo
    @fredericoamigo 25 วันที่ผ่านมา

    Best explanation i've come across so far. Brilliant and simple. Wonderful vid! Thank you so much for this!

  • @oliverdo2163
    @oliverdo2163 6 ปีที่แล้ว +8

    This is the best explaination of avl trees, I have ever heard. Thank you for being so clear and concise.

  • @BloodHaZaRd666
    @BloodHaZaRd666 4 ปีที่แล้ว +19

    I wish I had Teatchers like him in my university.

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

    As someone mentioned below, the last example is incorrect. But when we think about why, or how it should be done, we shouldn't start at the top and go down. We should think recursively, based on how node insertion works. Node insertion starts at the top of the tree and recursively descends until it finds the place to add the new node. Then, after adding the node, we unwind the recursion, returning back up the tree, updating the height as we go, checking each time whether the tree is unbalanced. In the example the tree is not unbalanced until we get back up to the root node, 4. That's why the (double) rotation should be centered on 4 (right on 10 and then left on 4, as mentioned below).

  • @jakethewoz
    @jakethewoz 4 ปีที่แล้ว +14

    5:36 - What he means is he has a height of 3 children on the right of the four. This is why AVL trees call them 'heights' and not 'children', because it can be very confusing otherwise. Here, the four seems to have 4 children, but what the teacher means is that the height of its children is 3.

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

      thank you, that had me very confused

  • @glowstonedust680
    @glowstonedust680 4 หลายเดือนก่อน

    this guy is insane the way it was explained it made so much sense

  • @fatihsonmez
    @fatihsonmez 6 ปีที่แล้ว +37

    "so my tree is happy"

  • @slitynskyy
    @slitynskyy 5 ปีที่แล้ว +9

    @RobEdwardsSDSU
    , there are several mistakes
    1. Minor, there are number 8 written as 6.
    2. Major - you are rotating wrong numbers near 6:00. You should rotate right and get 8 parent of 10 and 10 parent of 9 and 12 ( 9/10\12 ) and then rotate left and make 8 root.

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

      Agree, around 6:00, the violation node is 4, we should do a right left rotate on the subtree of 4 - 10 - 8, www.cs.usfca.edu/~galles/visualization/AVLtree.html this helps me

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

    This was exactly the instruction that I needed to understand height better, and to understand rotations. Thank you.

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

    Breaks down the problem properly. Love it

  • @freshbreeze6180
    @freshbreeze6180 8 ปีที่แล้ว +9

    Thanks a bunch. The best explanation ever.

  • @jalajkhanna6796
    @jalajkhanna6796 6 ปีที่แล้ว +31

    how come first time 9 is considered to be the violating node and not 8.
    And later after left right, 10 is considered the violating node and not 12.
    How do we select the violating node ?

    • @CharlesPieczonka
      @CharlesPieczonka 6 ปีที่แล้ว +23

      This last example is incorrect. Even though inserting 9 caused the violation, you only go down the tree 2 nodes from where the violation of rules occurs towards the violating node and choose that node's parent and grandparent for the rotations. In this case, the violation of rules occurs at node 4, so we go down the tree two nodes towards 9 and end up at 8. Then we perform a right rotation on 10 (the parent of 8) and a left rotation on 4 (the grandparent). This balances the tree in one set of rotations.

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

      diese ubung ist nicht richtig

  • @sujaysshenoy247
    @sujaysshenoy247 6 ปีที่แล้ว +25

    awesome explaination. ..but how is he writing those letters on glass.

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

      My mind is fucked rn. Is he writing backwards?? Is the footage mirrored? I must know

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

      @@natecolbert959 Yeah, he's writing with the left hand and since most write with the right hand, I'd guess it's mirrored :D

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

      He's wearing a nike shirt, so yeah it's mirrored

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

      @@ginicholas4322 I like how we are all watching CS videos and you're the only person who used logic to determine the video is mirrored. -_- our future is doomed.

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

    You are doing awesome lectures! Thanks so much!

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

    Thanks very much Dr. Rob, extremely well articulated information! Love the analogies. Home-wrecking single parents lol

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

    Thank you so much! Your videos on avl trees are great!

  • @diegocruzalves
    @diegocruzalves 7 ปีที่แล้ว +5

    Excellent explanation!

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

    Are you writing in mirror image? If so, that is impressive.

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

      I’ve been trying to figure that out, too. But I have a theory: Most people are right-handed. But he appears to be left-handed. So maybe he records them and flips the video afterwords. Or maybe he’s just left-handed and this is a live recording of a lecture. I couldn’t say for sure.

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

    Great videos. Balancing makes a lot more sense, now.

  • @惜小夜
    @惜小夜 2 ปีที่แล้ว

    Excellent video, helped me so much. Thanks!

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

    Hi so those super-scripts next to the node represent the height of the sub tree right? When you say children on the left or right you mean “generations” right ?

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

    Great explanation, thank you Rob

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

    Would it be wrong if we balance the tree even if the height is less than or equal to 1. It might not be useful but would it be wrong?

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

    Ok the video might be flipped....but what about him looking around like there are students in front of him?

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

    I love your EKIN t-shirt

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

    great job explaining this! thank you

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

    Nice explanation, thank you!

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

    hello sir, does Red Black Trees and AVL Trees have different rotation method?

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

    The second example is wrong unless there are multiple ways of balancing an AVL tree--it's suppose to be a right-left rotation (not a left right rotation)

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

    Awesome explanation

  • @icosmini
    @icosmini 6 ปีที่แล้ว +10

    Not sure why he is talking about the number of children. What is important is the height of the nodes, not the number of children.

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

      this, confused me so much

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

      the height of the node is the number of children of the node

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

      thats the same thing

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

      @@jozicar Me too. It seemed like he had 3 children on the left of the 10 and he was saying 2 children. Thanks @Cosmin for explaining this.

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

      @@chanpreetsingh5054 it is not, at 5:42 he says that the 4 has 3 children, but it has 4. What he means is the height/depth of the node.

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

    exercise 3 can be resolved with right-rotation(10) and left-rotation(4) ?

  • @georgevasiliadis4228
    @georgevasiliadis4228 5 ปีที่แล้ว +132

    who cares about the trees
    that dude is writing like backwards, teach me that instead

    • @HappyLeoul
      @HappyLeoul 5 ปีที่แล้ว +31

      lol, I was thinking the same, but he is probably writing normally, then the video is flipped :)

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

      I think maybe there is a mirror somewhere lolz

    • @YellerMetal
      @YellerMetal 5 ปีที่แล้ว +9

      Just look at the nike symbol on his shirt. It looks like he is writing with his left, but it's actually his right.
      The picture is simply flipped

    • @definty
      @definty 4 ปีที่แล้ว +1

      No he is writting so he can see it. He then mirros the image in a video editing package.

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

      give ariel a job at google

  • @matt-ex5ub
    @matt-ex5ub 5 ปีที่แล้ว

    very useful video now i understood thanks

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

    Thanks. Great explantaion!

  • @楊宗儒-i7o
    @楊宗儒-i7o 6 ปีที่แล้ว +1

    it's cool. How to write on a blackboard like through a glass?

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

      Looks like he is writing on the glass and the video is flipped so that it doesn't appear backwards. Note the flipped image of the Nike logo on his shirt!

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

      His left hand is actually his right hand.

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

      @@DevinSamarin mate you smart, i didn't notice that. Anyways I wish you a good day sir.

  • @EricSmith-ts2pj
    @EricSmith-ts2pj 4 ปีที่แล้ว

    at 5:53 ... why isn't the root the violation? can't you just do one rotation of the root to its left child from the start to fix it?

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

    Hi,
    I've a problem with creating a Balanced AVL tree . In the following there is a sequence to create. The issue is I can not create a Balanced tree with a difference of 1. If you try to rotate the nodes in my understanding I am entering to an endless loop. I'l appreciate very much if someone can explain me on how to create from this sequence a balance tree.

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

      Sorry here is the sequence.
      Thanks
      vector v = { 43, 18, 22, 21, 9, 6, 8, 27, 4, 2, 13, 7, 10, 16, 3, 15, 1, 11 };

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

    Well explained!!

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

    2:40 you write 6 instead of 8

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

    Does anyone have an idea where and how he is writing? It's definitely not glass! Is he using a software?!

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

    perfect Explanation

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

    do you mirrow writing? how is it possible that I can write the letters on the glass XD

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

    Does he have an audience?

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

    Wait! He doesn't write backwards, it's Nike logo is reversed. The video is mirrored!!
    A legend has fallen...

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

    wait, are you writing backwards?

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

    That is not called two children on the left and one on the right, each node has a maximum of 2 children! You should say the height of the left subtree is two and the height of the right subtree is one.

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

    first example, from where did you get 6?

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

      That's 8, either it looks like 6 or he wrote it by mistake.

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

      Yes, he made a mistake.

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

    What Hank would've looked like if he hadn't become a police officer and decided to be a college professor.

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

    r you writing backwards?

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

    Why does his Nike shirt backward

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

    Nice visuals, but you lost me when you did the left right rotation, that's why in the end the vid, as nice it may looks, doesn't really help me...

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

    At first, I thought that he used Bunshin no Jutsu.

  • @thrakiamaria
    @thrakiamaria 6 ปีที่แล้ว +5

    there is a mistake in 3:09 the number is 8 not 6

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

      Look closer its 8

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

      @@zbynekjuros5139 the left child in the left rotation must be 8, not 6. But it doesn't change anything.

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

      ​@@thrakiamaria so one more time? Its 8. Zoom in.

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

      Are you sure its definitely a 8? it looks like a 6

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

      @@adityamehta2819 it looks like 6, I zoomed in, except if you have 4k screen.

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

    @5:45 4 children at the right of 4? right?

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

    at first i was like whaaaat this guy write backward then i got it

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

    he should have said 'max subtree height' instead of 'child'

  • @haiphan9181
    @haiphan9181 4 ปีที่แล้ว +1

    This dude looks like how the villain from Riddick moves

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

    thanos: perfectly balanced :D

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

    horrible...not explained why the 10 is the one violatiing, how you decide the rotation? how you decide ll rotation vs l rotation? horrible.

  • @user-fy4iq6if4z
    @user-fy4iq6if4z 4 ปีที่แล้ว

    writing backwards??? yo...

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

    you write 8 like a 6