Lecture 6: AVL Trees, AVL Sort

Поделиться
HTML-код
  • Опубликовано: 13 янв 2013
  • MIT 6.006 Introduction to Algorithms, Fall 2011
    View the complete course: ocw.mit.edu/6-006F11
    Instructor: Erik Demaine
    License: Creative Commons BY-NC-SA
    More information at ocw.mit.edu/terms
    More courses at ocw.mit.edu

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

  • @sergeykholkhunov1888
    @sergeykholkhunov1888 3 года назад +95

    02:50 height of a tree
    06:40 height of a node
    10:40 AVL tree
    14:40 AVL tree balanced
    29:00 AVL insert example
    32:45 rotation
    40:05 general AVL insert
    48:42 AVL sort

  • @DaxXx988
    @DaxXx988 10 лет назад +549

    @45:00- it should be LeftRotate(x), not Right

    • @DeshRaj-sr1hy
      @DeshRaj-sr1hy 9 лет назад +44

      Yeah, exactly. I am surprised none of the students pointed that out, even though it's MIT.

    • @anonymoose_yt
      @anonymoose_yt 9 лет назад +34

      I went back and forth from 45:00 to the part where he did the left-rotate(x) originally and was sure I'd missed something. Thanks for clarifying. MIT's RUclips videos are some of the few with comments that are actually useful :-).

    • @Qladstone
      @Qladstone 7 лет назад +3

      This needs to be upvoted to the top of the comments section.

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

      RR means you have to left rotate, its used RR notation because you add a node to the RIGHT twice.

    • @yawofori-addae3888
      @yawofori-addae3888 6 лет назад

      so is everything else he says after right? with reference to the trees he drew

  • @adonis1168
    @adonis1168 6 лет назад +213

    all those beautiful mornings ruined for stupid classes whilst i could have listened to this guy at my warm bed with a cup of coffee at my hand. smh

    • @akntokluoglu2851
      @akntokluoglu2851 4 года назад +2

      Mesele dersi dinlemek değil aynı dersi aynı şekilde başka yerde de dinleyebilirsin

    • @LucasRibeiro-qb8bj
      @LucasRibeiro-qb8bj 3 года назад +4

      Dude, I'm feeling it right now during the class, my professor is kinda bad

    • @debasishghoshsays
      @debasishghoshsays 8 месяцев назад

      I am thinking the same blud lol

  • @melvin6228
    @melvin6228 5 лет назад +51

    05:42 that jump though
    #secret_teaching_skills

  • @CEngineer2010
    @CEngineer2010 9 лет назад +119

    @44:57 its called a left rotate of x. Not right rotate. He goofed up.

    • @RC_Cola2020
      @RC_Cola2020 9 лет назад +4

      CEngineer2010 This caused me so much confusion! I agree that he reversed them.

    • @chengweili9516
      @chengweili9516 8 лет назад

      +CEngineer2010 Yes. That's a left rotate of x!

    • @AmbarMehrotra1
      @AmbarMehrotra1 8 лет назад

      +CEngineer2010 Thanks man! I was so confused about that!

    • @TasdiqueChowdhury
      @TasdiqueChowdhury 8 лет назад +1

      +CEngineer2010 super upvote. this is really important lolol

    • @user13823
      @user13823 8 лет назад +23

      +CEngineer2010
      when I was a student, I often found mistakes in notes which I made at lectures. And I used to think: "o, the professors are so silly, even me, ordinary student, find stupid mistakes in what they teach".
      Everything reversed when I started to teach. I cannot explain this exactly, but something like magic happens. When you stand near the board and teach, you sometimes forget trivial things, and do such silly and stupid mistakes that even you cannot understand how that happens.
      It is not that easy to stand near the board and explain something to other people.

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

    Thank you, Erik Demaine. Your courses are always so clear and intuitive!

  • @acur665
    @acur665 7 лет назад +41

    It blows my mind that people can essentially get a free MIT education from these lectures. Thanks for all the CS lectures & the rest of the online courses! I look forward to absorbing as much knowledge as I can from them!

  • @aliaj.shafira7203
    @aliaj.shafira7203 4 года назад +6

    Thank you for this video, MIT! It helps me a lot to understand the material. And thank you to Mr. Demaine for the explanation. Your explanation is understandable.

  • @Mmspuff
    @Mmspuff 4 года назад +10

    i swear this is the best algorithm lecture you could ever find on internet!! I tried paid courses from other top universities and they are not nearly half as clear as MIT!!!! great MIX of concept and image rather than plain formulas and calculations!!

  • @shady1080
    @shady1080 9 лет назад +45

    I love this guys, so enthusiastic about what he's teaching!

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

      He’s a child prodigy for no reason

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

      Unlike indian profs 🔥🔥

  • @codewing
    @codewing 10 лет назад +33

    Thanks a lot! Way better then my prof in germany... Amazing how much better motivated ppl. can teach stuff! Keep up the good work!

    • @bluesystemjackson
      @bluesystemjackson 5 лет назад +3

      Ja, ich glaub die haben da auch ein ganz anderes Verhältnis als in Deutschland. Die Studenten dürfen ihn mit Vornamen anreden (es noch weitere Videos, aus dieser Vorlesungsreihe, wo er mehrfach mit "Erik" angesprochen wird", er redet mit denen Studenten, versucht einen lebendigen Vortrag zu entwickeln etc. Kein blödes Rumgedrücke mit Folien und Laserpointer, wie es in Deutschland gelehrt wird, sondern richtige Herleitungen Schritt für Schritt. Massachusist müsste man sein^^

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

    I love how the professor is kinda dancing while cleaning the board @ 26:05

  • @kazenohito7641
    @kazenohito7641 8 лет назад +162

    Oh my god I wish my instructor was like this. I swear my csc instructor just pulled rotations out of his mitochondria and did not explain a lick of how they work.

    • @ninatsvetkova
      @ninatsvetkova 8 лет назад +32

      At least you learn about the avl tree in your university...

    • @eRaZerrOfficial
      @eRaZerrOfficial 7 лет назад +9

      same dude...same...At least your teacher speaks

    • @ra1zoo
      @ra1zoo 7 лет назад +16

      at least you went to university...

    • @ausseriridische976
      @ausseriridische976 7 лет назад

      Haha this is why I believe this video has so many views :[

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

      @@Retrosenescent "Bad english is the language of science"

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

    Thanks MIT and prof. Erik for the fantastic lecture on AVL trees

  • @zhanghewnn
    @zhanghewnn 10 лет назад +4

    It is a enjoyment to watch Erik's lecture! Greetings from Dalhousie!

  • @op1ekun81
    @op1ekun81 7 лет назад +40

    At 45:00 isn't it LEFT ROTATION of X instead of RIGHT ROTATION of X?
    UPDATE: Already pointed out by DaxXx988 in the comments below. Thanks!

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

      Dude I thought I was the only one. The teacher, towards the end, was tired and as confused as the rest of us.

  • @user-gf7yo6uu1q
    @user-gf7yo6uu1q 2 года назад

    SO good to see those teachers would take time to encourage students to pause and think what just happened

  • @NikhilKumar-fj2dg
    @NikhilKumar-fj2dg 7 лет назад +7

    Thanks a lot professor for solving my doubt of AVL Tree and also thanks to MIT

  • @TheTownLord
    @TheTownLord 11 лет назад +2

    Very strong lecture! Clearly understandable and Smooth

  • @SneakyMrSnake
    @SneakyMrSnake 9 лет назад +1

    Great lecture! Really helped to understand AVL trees for my exam

  • @nap6793
    @nap6793 8 лет назад +1

    Hey, how do we do to define which node is ''x'' oder ''y''
    And in double rotation who is ''x'', ''y'' or ''z'' please? thanks!

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

    Nice lecture I got clear image in my mind. Thank you so much sir

  • @gamereplayhq
    @gamereplayhq 6 лет назад +1

    Beautifully explained

  • @vothuong08
    @vothuong08 6 лет назад +1

    thanks MIT & professor for this video

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

    @49:16, the instructor mentions the insertion time for AVL try is nlg(n), is it because we have to talk about the worst case when we are talking about insertion time? Since it seems it assumes all the insertions are going to the leaf node?

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

    @34:55, I don't understand how he checked formally. "B contains all the nodes between x and y" -what does this mean?
    Could someone please help me?

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

    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 not more than 1.

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

    Log (n) = height for balanced trees. On the example on 5:20, there are 15 nodes, height is 4, but Log(15) = 3.90689059. Wouldn't it be height = Log (n+1) ? What am I missing? Or "+1" is considered a constant, so it is not inserted into the equation?

  • @bsethupathi1
    @bsethupathi1 5 лет назад +5

    31.57 : "This guy is doubly left heavy.
    Hmm, Bad News."
    Cracked me up.

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

    Does the abstract data type have the feature 'search' that BST provides as well?

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

    Erik's explanations are great! Thanks to MIT.

  • @ga63r4h
    @ga63r4h 11 лет назад +2

    if node height = max height of the left + max height of the right + 1 shouldn't the root of the tree at 9:35 = 4 and not 3?

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

    @6:42 how is the height of the node equal to the level of the node? Isn’t the Level the depth..? Can anyone help here if I misunderstood levels?

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

    Why in the lecture note on page 6 the running time for findmin of AVL tree is constant?

  • @yyyyzzzzify
    @yyyyzzzzify 10 лет назад +2

    Have a doubt about BST in this lecture, where professor writes >=x and < =x that shows nodes in left subtree are equal or less than its parent...same on another side. Isn't BST supposes to have no duplicate nodes, which means nodes in left subtree must be less than its parent not equal or less, and nodes in right subtree must be greater than its parent not equal or greater?

  • @angelc4794
    @angelc4794 4 года назад +15

    For some reason the Frisbee cushions bring me such joy. xD

  • @minksq4026
    @minksq4026 7 лет назад

    Those tree nodes are so cute

  • @IgnisArdor
    @IgnisArdor 8 лет назад +4

    I'm a Maths student from Italy and my exam is tomorrow! thank you so much for sharing these!! they're so useful!!

    • @tryingtocorrect
      @tryingtocorrect 7 лет назад +2

      But why did you leave it to the last moment? :)

    • @IgnisArdor
      @IgnisArdor 7 лет назад +4

      I had been studying for a month, i was revising. Passed it.

    • @darshanbhatt6293
      @darshanbhatt6293 7 лет назад

      g

  • @micmicmic7
    @micmicmic7 11 лет назад +1

    Great lecture, thank you very much!

  • @bachirmasry6233
    @bachirmasry6233 8 лет назад +39

    If we could listen to the students remarks and questions, that would make this video in my opinion mush more beneficial.

    • @Hamza-qk9yq
      @Hamza-qk9yq 6 лет назад +15

      You can turn on the subtitles, it shows what the students are saying

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

      There must be some sort of translations in the course's website

  • @ashutoshtiwari4398
    @ashutoshtiwari4398 4 года назад +6

    At 27:30 ,
    how did he get N(h) > 2*N(h-2) to N(h) > theta(2 ^ (h/2) )

    • @--ShivaS
      @--ShivaS 3 года назад

      did you get the answer for it ?

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

      N(h) > 2 * N(h - 2) > 2 * (2 * N(h - 4)) > 2 * (2 * (2 * N(h - 6))) > ... > 2^k * N(h - 2k) for some non-negative integer k and recurrence ends when N(h - 2k) reaches base case N(0) for k = h/2.

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

    24:50 a random n appears in the reasoning whereas we were always talking in terms of N_h, h, and phi. He meant phi^h / sqrt(n) < N_h

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

      i got confused for a while, maybe thats what reviews are for

  • @suramshivakumarreddy
    @suramshivakumarreddy 9 лет назад +6

    i'm very impressed by the way u taught :)

  • @yajurphullera9396
    @yajurphullera9396 3 года назад +11

    25:39 "Now if you don't know fibonacci numbers, I pull a 'rabbit' out of a hat and..."
    I see what you did here Eric.

  • @WS-lv4kk
    @WS-lv4kk 6 лет назад +1

    At 46:55, and was noted at another point earlier that there may be an imbalance in the higher levels of a tree if an imbalanced node is balanced at a lower level of the tree. Is that really true in a properly coded AVL tree? A properly coded AVL tree is balanced at the moment of insertion. After insertion, node X is imbalanced because of, let's say, right-heavy right subtree Y. After rotation(s), Y is now at the previous location of X, and Y has the same height as X before the insertion. This is because Y's height increased by 1 as a result of insertion, and now has the same height as X before insertion. Moving Y to replace X in the rotation means the height at the NODE OF ROTATION does not change. Therefore, the only way that there could be further imbalance up the tree is if the tree was already imbalanced before insertion.

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

    Amazing! Greetings from Mexico.

  • @Cnidaria14
    @Cnidaria14 11 лет назад

    i think that 45:13 it is a left rotate not a right rotation. can someone help me pls? since he's moving the x to the left thus it is a left rotation

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

    Another reason to give NULLPTR a value of negative one is that you have to move upward once to get to a genuine leaf.

  • @malikalamgirian
    @malikalamgirian 7 лет назад +10

    At 46.00 is a left rotate, not a right rotate

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

      RR means you have to left rotate, its used RR notation because you add a node to the RIGHT twice.

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

    how to check if the node is even, left heavy or right heavy???????????????

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

    At 44:58 shouldn't it be left rotate of x insyead of right?

  • @shrikantsarma27
    @shrikantsarma27 7 лет назад +17

    Damn good prof. ... Need more videos from him !

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

    27:32 "... I'll just write theta to avoid the base case"
    Does anyone know what that means?

  • @rudymagasrevy2110
    @rudymagasrevy2110 11 лет назад +3

    this guy is a magician with chalk

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

    He sometimes switches between 'depth' and 'height', but the depth or level of a node is it's distance going down from the root, right?
    Also I've seen different ideas about whether the root of a tree is at level/depth 0 or - 1. Is there a widely accepted consensus on which should be used or is it just a matter of consistency with the formula/algorithm in the same way that null nodes were defined to have height - 1 here?
    The notation and terminology around this topic is a tad confusing...

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

      I think level and depth are same but height and depth are different.That -1 theory for null nodes is widely accepted and about that root being at level -1,I've never come across any algorithm which assumes the level/ depth of root of a tree as -1.

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

    MIT &Erik you owe me for this!!
    Don't judge by edit sign on comment i misspelled Erik Lol😁

  • @gosumadman
    @gosumadman 9 лет назад +14

    Can someone explain 26:09?I don't get why he changed N(h-1) to N(h-2) and removed the 1. Also I don't get how 2N(h-2) = (2^(h/2)

    • @jonsnow9246
      @jonsnow9246 7 лет назад +2

      Yes,but how?

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

      Thanks! By the way, why h is decreasing by 2? Why the second line should be N(h-4) instead of N(h-3)??

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

      it is more convenient to use log, I guess. If you use N(h-3), then you get N(h) > 2*N(h-3), nothing helpful

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

      Becase N(h) > 2N(h-2) and h replaced by h-2, the righthand side becomes N(h-4). Actually you can write this process as N(h) > 2N(h-2) > 2*2*N(h-4) until N(0)

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

      Sagar Theurkar Thanks a lot! I had a same question and little trouble to derive the last from the first. It was not only me who have the same.

  • @Jorgetime
    @Jorgetime 11 лет назад

    This teacher is awesome

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

    at 44:58 he says do a right rotate, but isn't what he does a left rotate?

  • @websoftwaredeveloperijtiha3093
    @websoftwaredeveloperijtiha3093 Год назад +1

    It's so cool that these top schools release courses like this one online free of charge. I may not get a chance to go to MIT

  • @woshikakadong
    @woshikakadong 6 лет назад +1

    I love this prof

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

    Literally a genius.

  • @Stu49583
    @Stu49583 9 лет назад +1

    great teacher

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

    Thank you MIT.

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

    He really loves that board

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

    Can anybody give an example when you need more than two rotations? After one or two rotations height of an unbalanced subtree remains the same it was before insertion, doesn't it? So I don't understand why we might need more than two rotations.

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

      maybe when you are given a task of Converting BST to AVL

  • @sonikaagarwal931
    @sonikaagarwal931 2 месяца назад

    I study at UNIMELB and this is so much better...and this is in 2011.

  • @scottwells9340
    @scottwells9340 8 лет назад +16

    @31:30 "now all the heights change... and it's annoying to draw what the heights are... but... I'll do it"

  • @sachoslks
    @sachoslks 11 лет назад

    are the hard seats made on purpouse? lol

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

    Tree rotation is magic.

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

    At 11:38 . Why not define the empty left or right tree as height = -1 and not as you mention deept = -1.

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

    Thanks a lot Sir.

  • @tjfirhfjejUTH24
    @tjfirhfjejUTH24 11 лет назад +3

    he also blows glass. like a badass

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

    in at around 39:00 he is rotated the tree. ok but it is not exactly same as the previous. means he rotated the previous ---- axbyc --- and rotated the result same. but at if her double rotation at 65 . it has to be 55 -50- 65 but the result is 50-55-65. not the same as the previous.

  • @jungsuheo5874
    @jungsuheo5874 8 лет назад +7

    Is Erik out there? or could someone help me?
    I have a question.
    At 45:20, RR(x) should be changed to LR(x) or RR(y)? it violates 35:21
    Thanks.

    • @tannernewton8543
      @tannernewton8543 8 лет назад +3

      It should be LR(x)
      RR(y) would be something completely different but you are correct

  • @ericbelrose1984
    @ericbelrose1984 9 лет назад +3

    Why didn't he start with a balanced tree. Is it not true that before he inserted the 23 the tree was already off balance. The tree was left heavy.
    I am still just starting the study of this structure, but it would seem that the tree would have to left rotate at 20 so 29 becomes it's parent and 26 joins it. Then the left subchild of the left subtree is heavy so it would right rotate so 29 becomes the head.
    Maybe it is because he knew he was going to add the 55 and didn't care that he didn't start balanced. If he did that rotation first the tree would be a perfect tree after adding the 55.
    Perhaps I'm confused.
    It would seem that you could improve the algorithm simply by looking beyond the max{HR,HL}. Could you not calculate optimal tree height for N and if max height after walking down to insert in the BST fashion is worse, then start rotations on the max height side.
    First step towards that side being heaviest in that side (left heavy where left is the issue/right heavy where right is the issue), then balance the head node by rotating away from the heaviness. Is there another name for that tree balancing algorithm.

    • @melode221
      @melode221 9 лет назад +2

      Eric Belrose The tree at start point is not complete balanced, but is indeed `AVL balanced` which means it obeys the constraint of AVL tree, so it is a possible real world case you'll dealing with.

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

      the tree was left heavy but only by a factor of 1 over the right side. The idea is to keep the lack of balance either 0 or 1 to either side, but not larger than that 1. Otherwise if you forced a perfect balance of 0 at all times, you would be entirely unable to modify the tree, since you can't add two nodes at the same time, and if you did, you'd have to then add four nodes at the same time the next time and so on. If you allow it to be left or right heavy by at least a factor of 1 then you can add nodes as you go and then rebalance the tree if it's necessary, because you allow it to have empty spots. If that wasn't the case, say you have only the root node, and you want to add a child to it. You just can't, because that'd already make it either right or left heavy from the start, and so that would break the 0 balance factor.

  • @mikkelrivera
    @mikkelrivera 11 лет назад +1

    I think he may have made a mistake. He defines N(h) as the minimum number of nodes in an AVL tree of height h. In my opinion N(h) = 2^(h - 1) + 1 (I think a student suggested that but he never really elaborated on why that was wrong). As I see it, you take the perfectly balanced tree of height h - 1, and you add only 1 node to increase the height by 1.

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

    @11:13 - Would like some confirmation on this, did he mean "height" to be -1 when he said "depths"?

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

    keep the height order log n to keep the left n right tree balanced

  • @user-is2qn8so5j
    @user-is2qn8so5j 6 лет назад

    здравствуйте, объясните пожалуйста, как этот бизнес растает.

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

    AVL Insert algorithm is incorrectly described as possibly requiring more than 1 or 2 rotations and having to travel up to the root. After 1 or 2 rotations retracing is done. I skimmed the video waiting for delete() and it isn't there, delete rotations can introduce further imbalances up the tree. For an example of the insert see: refactoringlightly.wordpress.com/2017/11/05/rank-balanced-avl-trees-on-github/

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

      Yeah, you're right about the amount of rotations required after inserting a new element. I was confused when he said about needing to traverse the AVL up in order to find any new imbalances so I was looking for a comment like yours to confirm my doubt xD

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

    Earlier i was sad :( now m happy :) thanks Erik

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

    How come N suffix (h-1) + N suffix (h-2) got converted into 2*N suffix (h-2) ?
    Timestamp : 28:31

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

      We know that N(h-1) > N(h-2) as the latter has one less layer/height from the former. Therefore adding N(h-2) on both sides, N(h-1) + N(h-2) > 2 N(h-2). Hence if something > N(h-1) + N(h-2), it is also > 2N(h-2)

  • @Cnidaria14
    @Cnidaria14 11 лет назад

    no if you look at the maximum height of the children it is 2(maximum) since the last node has a height of 0. ok?

  • @annaz1652
    @annaz1652 8 лет назад

    @46:08, why is it k-3? The triangle is connected to the X? similarly, the B triangle is connected to Y which is k-1 and C is k-2, but B is k-3?

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

      because the earlier assumption is "suppose x is the lowest node VIOLATING AVL", if x is k-2, then x will be AVL, thus contradicts the assumption.

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

    at 37:25 he says that the 65 node is doubly left heavy, how is this? Can somebody please explain this?

    • @Elif-ww1fw
      @Elif-ww1fw Год назад

      exactly, how it is doubly left heavy? it seems like a balanced tree to me. Am I missing something?

  • @seinj9013
    @seinj9013 9 лет назад +2

    40:47 - not sure it's correct that "we might have to do more than 2 rotations"
    after a violation fix, the tree should become re-balanced again

    • @mlazowik
      @mlazowik 8 лет назад

      +korvix He explains that just after what you quoted. By adding a node you make all of the (left or right) subtrees of nodes on path from root to the added node larger. This one violation fix fixes only one of these subtrees. Others might have to be fixed too.
      Otherwise each operation would have a constant complexity. That'd be lovely, but unfortunately it's not true :(

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

      yes you are correct: when a node is balanced after an insert, it will have the same height as before the insert, so after doing a post-insertion rebalancing of the first unbalanced node, you can terminate. in contrast, with deletion, you need to rebalance all ancestors.

  • @TonyNguyen-mc8bh
    @TonyNguyen-mc8bh 10 лет назад

    BST has not a same Node...X-node can't equal X-Root in this case

  • @LRP-84
    @LRP-84 5 лет назад

    Very nice your lecture

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

    Thanks for explaining this. I can't believe how those students just wonder in late ,, given the opportunity they have

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

      because it gets filmed and put online.

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

      @@TheMasterfulcreator ?

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

      @@jonsmith1271 i'm saying i probably wouldn't worry too much about seeing the entire lecture if it all gets recorded and put online anyway

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

    at 42:50 didn't he mean that the left sub tree is -1 and the right one is -1 and that's why it comes out -2? If it was 0 like he says then the node would be balanced

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

      also at 44:20 it seems like if you're AVL tree is good, it will never happen that node x is unbalanced and at the same time x's right child will be balanced.

  • @7yep4336dfgvvh
    @7yep4336dfgvvh 2 года назад

    Good stuff, thanks bro

  • @PuneetJainfca
    @PuneetJainfca 10 лет назад

    The lecture is AWESOME. but yeah, the LR thing and the heights of that tree in the question.. that isn't (h-3)... else the right child would be left heavy.. (lesser the height, lower it is..).... just my point of view.... I love these lectures :D

  • @apartment_prishtina
    @apartment_prishtina 11 лет назад +1

    cushions, everytime they get a right answer they get a cushion because the seats they sit on are hard seats.

  • @geekoist
    @geekoist 10 лет назад

    @4:45 when writing the inset operation Erik got the direction wrong. It's a left rotation

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

    guy walking in at 1:50 is a treat!

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

    after 7 years , still excellent

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

    Viel besser als unsere Algorithmentheorie-Vorlesungen

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

    And the people said that you have to become a nerd to be smart and here we have Eric :P

  • @nbafanboi23
    @nbafanboi23 8 лет назад +1

    I can tell that the students are pretty smart, just comparing it to my class at University of Waterloo. Although I can't tell if its the same students answering the question. I know that I would be clueless for half these questions.

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

      Waterloo is a pretty damn good school.