 In our previous video, we talked about a right rotation. Well, that's not the only rotation. Say for example, we have over here, we actually have now in our case a right heavy tree. But say for example, I were to come in, and I were to make an insert 8. All right, well, binary search tree rules apply. I would see that I'm greater than 5, greater than 6, greater than 7, and so since 7 has no children, I would come in and give it an 8. Now, the other aspect that we have to look at when we're dealing with an AVL tree is every node that happened to be affected by that, we have to recalculate out their balance. So in this case, we see that 8 has a balance factor of 0, and this is because there are no nodes for 8 to kind of go to afterwards. The balance factor for 7, well, it doesn't have anything going on here. So technically, we would classify this as a 0 for our left, and so right minus left, 1 minus 0. It does have a 1 here. Again, it is a right heavy subtree, if you will. But for our sake, that's still perfectly fine. But as we move up a little further, all right, well, we see the difference coming on here. You see, if we thought about that 7 and that being sort of an invisible node that had a balance factor of 0, I have another invisible node right here. That's the sibling of 7. That also has a balance factor of 0. So when I start to calculate out sort of the depths between 6 and 7, or the left node and the right node, for my balance factor here on my 6, I see that I'm going to have going down 1 and 2. So my right node can go down two times, and my left node can go 0 times. And so my balance factor is at 2. It's a positive 2. So it's a little too heavy. Now, like I was saying, what we can do with this is we can still do that idea of a rotation. Instead of doing a right rotation, like we did in our last video, we can do a left rotation. So the entire premise is once again, we take our nodes, our heaviest node, and our parent, and we simply rotate to the left. Now, the same principle that we were seeing when we deal with a right rotation comes into play. I have some parent node, and it has some child x. Now, the parent node and the child node, if you will, also have some subtrees. These subtrees are acting as potential children that might also be existing inside of our overall tree. And so we can label them out as t1, t2, and t3. Now, the idea with that left rotation, just like we see I have that arrow pointing over here, we're going to take our child node, and it's going to become the parent of our parent node, our previous parent node. These subtrees still need to find themselves in the correct place. So the t1, as we notice, has to be less than y, and it's also less than x, because everything to the right of y is greater, everything to the left of x is less than, and everything to the right of x is greater than. So what we'll see happen when we do this left rotation is, again, y is going to become the child, x is going to become the parent, and these t1, t2, t3 subtrees have to go in some way. Well, y happens to have the ability to house two children, and x only has the ability to house one other child, aside from y. So again, as I was saying, t1 has to be less than y, and if it's to the left of y, that means it's also less than x. So we can give t1 to y. Same thing can actually happen right here, just like we saw with the right rotation. That t2, that middle, is exactly that. You can sort of see that approach going on right here, that in this nice little wiggle room, we see that we're greater than y, but still less than x. I'm to the right of y, and I'm still to the left of x. So t2 can find itself here. Finally, at t3, we already established was larger than x, so we can just go ahead and put it to the right of x. So let's actually take this idea, this left rotation, and apply it to our example here. So as we said, I'll just kind of move down a little bit. Five has no change. Same thing is happening with two. Those aren't really being affected. It's now a matter of what we're doing here and what kind of occurs in our sort of arc. So if we were kind of labeling things out, that parent child is my y, that x, that heavy node, the heavier node is our x, and same kind of thing. We have a t1, t2, and t3 that still need to get applied. So we could say, for example, this is my t1, this is my t2, and this is my t3. As we can see, we still have that same kind of approach being made. I can take the same model we have here. Two isn't being applied. Five isn't being applied. However, once again, I take my x and it becomes the new parent. My left child is going to become the y, the y, and t1 and t2 are going to y. Well, t2 and t1 and t2 are blank. So I don't have to do much there. However, I do have a t3. So I just come in and I make my eight. Once I've made this change, I do still need to check myself, did I make a good enough fix? So in this case, the balance factors of eight and six, luckily are zero, since they are leaf nodes. And if I check the balance factor of seven, 0 minus 0, or 1 minus 1, sorry, 1 minus 1, it gets a zero. And so as a result, we can see that our tree has now become balanced.