Once again, picking up where we left off, let's go ahead and start these quotations.
I just want to break them in a different videos because it seemed like.
A lot of stuff to take in and just one video and the videos can get kind of long, so you know, this
video can take a while for sure.
So I'm going to start out with the simpler rotations, so.
We'll start out with like left left and left right.
So let's go ahead and start out with this left left.
So do you know, pointer a real tree left left rotation?
And so what am I going to do?
Right off the bat is declared some pointers to our.
Routes left, and I'm also going to do the routes left right, and so we'll look at the picture in just
one second.
So the path note calling and route that is going to be left, this RL is going to be the route left
some tree.
And then I'm going to do node pointer rlr equals or else right century.
And so let's look at why we're going to do that.
So let's look at that left last rotation.
So I've labeled them right here, so we have the route which is getting passed to our function that's
enroute.
Then we have it's right, we have routes left and then we have routes left right, which is why I call
it our alarm.
And we're doing we're labeling these because we notice in these pictures that we are going to have to
break this sub off and attach it to route when it gets moved here.
So this is just basically each time we're going to have a few nodes, like three or maybe four nodes,
depending on the type of rotation that we're doing that we have to keep track of when we're changing
pointers and stuff like that.
So let's kind of absorb the steps in this process.
You might already be familiar with these from our first lecture, but let's just make sure that we understand
what we need to do here.
So this is a left left rotation.
We are marking the route and routes left.
And the first part of the rotation, we're seeing that what we do is we're basically just bringing this
route down right here.
So if you have the left left and we were just thinking about the simple example that we're going over
these three nodes here.
I kind of what we were wrote like involving in our really simple explanation of the rotations, and
we just brought this thing down.
So this route known as going here where this rlr blue note is and since is going right there, we need
to kind of like, you know, we're moving this thing out of the way.
And since route comes down here and it had this left sub three pointer on it, you noticed that this
left some three pointer is just kind of dangling now.
And, you know, since it was a left sub three pointer and since this blue node technically part of
its left sub tree, she knows you had to go left to access this.
That's why we're going to go ahead and attach this as the left some tree of route after we performed
this rotation here.
So let's go ahead and do that.
So what I'm going to do is.
Say the RL, I'm going to say, ah, ls, right, some tree, some and do that little attachment first,
actually.
So we're talking about RL here.
So RL, it's raised some trees, and now we're now we're talking about the blue note.
So that's what our ALS rate cemetery is.
And what I'm going to do is set that to.
The enroute.
So RL, right, century.
Gets set.
To intrude so.
That is doing this part right here.
So I'm referencing that first, actually.
Well, then we'll do this part next, so first part bringing this down and we're setting it to this
is basically so are orals rites of tree, which is like this pointer here is getting set to intrude.
So you can see that right here.
Earl is now to enroute.
And now let's do this part right here.
So then we're going to say in enroute, it's left surgery.
It's going to be set to rlr.
So let's go back and look at that.
So in roots left, some tree is being said to rlr because rlr was part of its left some tree in the
beginning before the rotation there.
So here we go.
This is route left.
Some tree is now rlr for our famous picture there.
OK, so we're going to do a another thing here.
So if the path node was the route, then we of course, need to update route to the new route.
So I'm going to say that path node was the route then of that route.
Like we're talking about our actual route of the tree needs to be updated.
So.
We knew it.
So we're going to have to say if route equals enroute.
So this is the case in which we were rotating about the true root of the tree, the top of the tree
that node, then we're going to have to say that our new route is going to be our L right?
So let's go back here.
New route is RL, so let's imagine that we're not talking about this being a whole sub tree.
You know, the in the in the case in which this is not just a sub tree like the case in which this is
the root of the actual tree like the fully revealed tree starts here.
In that case, once we perform this rotation, the new root of the whole tree will be this RL.
So I'm not saying that.
It's always the case, I'm just saying that, you know, sometimes we're talking about rotating a sub
tree of the whole tree where this is some node in the sub tree, where the balance factor is off and
sometimes the actual actual root of the tree balance factor is off.
And so in that case, we need to change what we consider the true root of the tree, which is our private
member called Root.
So that is what I'm talking about.
All right.
So we set that and then we're going to return the root of the sub tree or the actual root, you know,
which I'm just going to say, return RL in either case, because that's what it is.
And then we go we have our rotation figured out, so let's go ahead and move on to the next one.
So I'm going to say no evil three are our rotation.
And then let's go ahead and declare these nodes just like before.
I'm going to say, ah, for roots, right?
So enroute right century and then I'm going to say R L and that's going to be R hours left, Sophia.
So let's take a look at that because we're doing our rotation.
So you notice we have this route, which is are for the route here, we have the right summary of the
route.
So ah, and then we have the right, some trees left.
So these are what we're considering because similarly, you know, similar to this one is basically
a mirror image we had rlr and now time we have ah, and this time we have our L because we're going
to need to take this and attach it to the end route.
Once we do our first rotation, so it's basically the opposite of what we just did.
So let's make that happen right now.
So we're going to go our hours left some tree, it's going to be enroute.
So that's that first part.
We're taking any route and we're moving it down.
And so now we have hours left, sub tree is enroute.
Hours left cemetery is in ruins.
Then we say in roots, right, it's right cemetery.
It's going to be our No.
So.
In Roots, Right Cemetery, so it's just left hanging there, and this was part of its cemetery originally,
so we're saying it's right cemetery is the cemetery, our area which got detached from here.
And that's the final picture we're ending up with there.
OK.
Same thing, we're going to need to do this kind of check here.
So I'm going to copy that and paste, and then we'll just do a small change to make it PR because that
is the new route.
So if you want to see that again, our our is our new route, so that's why we're doing that.
OK.
So let's go ahead and move on to the next one.
So our next one is going to be an R L rotation, right left rotation.
So I'm going to, you know, pointer Avielle three hour L rotation.
And so for this one, I'm going to say no pointer are equals in roots, right century, and I'm going
to say no to R L equals r left surgery.
That's true.
OK, so let's take a look at this situation.
We know this one's going to be a little bit more complicated and we're going to have to.
Make a little more changes than we did previously with the pointers, so let's go ahead and check it
out for this rotation.
So.
We're still going to be referring to three nodes, so we actually don't need to refer to any more nodes
than previously.
But we're going to have to.
I'm just not making like temporary pointers to these ones that we're going to become detached and need
to be changed and moved because I can just, you know, reference this guy's left and right.
So that's why I'm still just making.
Still just making our.
Two, I'm sorry.
It's actually just.
Two extra.
So previously, I made two pointers for besides enroute, and this time I'm doing the same, I'm making
two extra temporary pointers to be able to reference stuff.
So yeah, let's get to it.
We have here, we have this RR, which I already declared and it's our L.
So right here, our and our URL.
So that is all set up.
So what are we going to need to do first for this?
Well, we're going to have to set what I'm going to do is actually set our hours left sub tree.
To the drills, right, so tree, so I'm actually before I do this movement here.
I know it's ideal to do the weave into kind of thinking about doing the rotation this way first, so
we would like take our and move it down.
To.
B r ls sub Sudbury, so it's like this RL.
It goes here between these two and then we move R down.
So it's basically the way that we've been thinking about it with the two shifts is that RL would move
here and it would be between these two and then we would have our move down.
So RL would become the route into left.
Sub three would be, Ah.
So you know, that's why I have the R here with just the outline, because it came down, it was the
route, but we moved RL here and then we rotated it all reality and we rotated it down.
And so our I was at the top.
It was the roots.
But I'm going to do this part first.
So what I'm going to say is that I'm going to actually change this one.
I'm going to do this one for us, so we're going to be handling this right now.
I'm going to say hours left sub three is going to be our else.
Raise some trees to head the dark blue here.
So this dark blue is actually going to become R's left some tree.
So let's go ahead and do that.
So I'm going to say are
less tree?
Get set to our LS rate.
So tree, so and do that one first.
And then the next thing that I am going to do is set this one right here.
So I said, I want to do both these things before I actually do this rotation and change this pointer.
So I'm going to.
This is enroute America as it was right here.
It's our actual one that we're rotating about.
And so I'm going to set in roots right sub tree to our earl's left some tree.
This is the turquoise one right here, so that is going to have to be attached to here.
So that's what we do in roots, right century, Israel's left century.
So let's do that in root, right century is our else this century.
So got that out of the way.
All right.
So let's think about what we need to do next.
Let's look at RL.
So RL is our new route.
And so we basically need to.
Change what it's pointing to now because we moved it up.
And we moved this one down, and now it has a different left and right cemetery.
Than it did before, so previously it was these words right and left.
So I left and right some trees and you know, those are now.
Attached to these two guys, so we're going to have to update these right now, so this is a case in
which this is moved down.
And so now our else, I'm actually going to set this one first and say Earl's right.
Zebari is going to be ah.
And then we'll just also do our else left sub tree is going to be enroute.
So let's go ahead and do both of those right now are else right?
So tree is going to be our.
And we're going to say our allies.
Less than three, it's going to be equal to enrage.
And that's basically all good to go because we've already solidified these subsidies.
So that's kind of why it's a nice order to do this and because, you know, this is already attached
to here and this is already attached to here.
So now when we're setting these, we can rely on the fact that these subsidies are already complete.
You know, this sub tree is attached to here in the subsidies attached to here.
Now we can set the pointers for our new route here.
So speaking of the new route, let's also go ahead and handle that.
So I'm going to pass that right here, and, you know, our new rule is our L, so I'm going to set
that if it's the case that it was the actual root of the whole tree.
And then I'm going to return our URL.
OK, so I went pretty smooth.
Let's go ahead and do our final one.
So this is going to be the l r so left right rotation.
So do you l three l r allies.
If that a real tree LR rotation.
And so this one is going to be node r l in root left.
So tree and node are our equals are L's right, so tree.
Let's take a look at that.
So.
Left, right rotation.
Our final one, so we have.
The RL and rlr so are El and Al rlr as what we're considering this time and so very similar to the last
one.
You know, we're taking this, putting it right here.
Bringing this in route, which is the route down, and then, you know, first I'm going to do these
attachments, actually.
Before I set the new Eilers left and right.
So same thing.
Let's go ahead and get to it.
So let's set these two right here, so I'm going to do our else, right?
So tree is equal to this blue and here are ours left.
So let's go ahead and do that.
R.l
Island, you are al right.
Sub tree is equal to our al are
left some tree.
Cool.
And then, you know, the other one is going to be our enroute.
So, you know, our interview got taken down here, so let's send it to this Terkel's turquoise guy,
which is rlr right century.
So let's go ahead and do that.
I'm going to do in roots
left some tree, the sequel to our
right century.
And then, of course, let's set our new routes left and right pointers, since these are all set up
with the sentries.
We're going to do said it to our Elsa rlr as leftist Earl and rlr Wright is enroute.
So let's go ahead and do this.
Right our left.
So tree is going to be our ally and our our great century is going to be a bit.
And then we got to do this, too.
So what we're doing is we're actually setting to rlr because that is the new route.
If we go back here rlr is our new route in the final.
So it looks like this.
OK, so now we got all of our rotations here.
So actually, I know I've made a lot of videos for this, but I'm going to just have a short next video
edit right here.
And the next video is just going to be us printing out the tree.
You know, we'll we'll fix up our main because right now I just have like this hello world in Maine,
and we will go ahead and print out our tree and confirm that it works and everything like that.
So with that, I will see you in the next.