Hey, what's up, guys?
Welcome back to this video.
In this video, we're going to talk about insert operation and in this video specifically, we'll talk
about laterite condition.
Now, let's talk about laterite condition in details.
For the sake of understanding, let's assume we're given this ability and we have to insert a note of
value.
Three inserted this note to this will carry this note, will goes to the right of this node to since
this is a binary firstly because a filter is a binary circuitry and we have calculated the height of
every single node.
Now let's find out the balance factor, balance factor of this, not zero.
The balance factor of this node three is zero.
The balance factor of this node to is minus one mind zero and is minus one.
There is no node on the lips of three.
So the height of leptospira is minus one, minus one liners is minus one.
Then here one minus minus one.
That is two.
So this is inappropriate node because this node is not following the properties of every tree.
The balance vector is not minus one zero plus one.
The balance is two.
Here we see that inside is three, the Velone, that letterbox node, or they find it the inappropriate
balance factor two, and that is less than the inserted value.
So we have to do here let rotation first to do let rotation.
So let's do a little rotation.
If we do let rotation, if we do hear a little rotation, then our will be represented, something like
this for right condition.
We have to do now in right rotation.
If we do right rotation, then our event will be represented, something like this.
And this is the ballot.
We have every single that contains appropriate balance factor.
So this is the ability that we have to return.
And this is called let the right condition for that condition.
First step to do a little rotation then.
Right rotation.
Now, let's see how this actually works using pseudocode.
Listen to the court and sort of got exactly the same, the pseudocode in the previous video.
For sake of understanding, let's assume we're given this.
We'll try and insert a node three so the Node three will go for the right of this node to let's find
it the height of every single node and the balance vector of this node, the balance of this not three
zero balance making all this noise, minus one, minus zero is minus one.
Now, the balance of this, not four, is to because one minus minus one, that is two.
Now we find out this culprit.
Note this node is not contains the appropriate balance factor.
That is zero minus one hour plus one does not contain the balance factor two.
Now here we have to do that right condition first, let's call it with the left of this node for that
is to let's call with this, not my reputation and returning not all assigned to the left of this node
for by the segment.
Now, let's see.
This rotation is your little rotation pseudocode.
Here we have current and neonate area of current node and new route.
Now what we have to do, current node dot radical's to current, no dot right, dot left.
So current node that right.
Is this not the one that is now.
So we have to insert to the right of node is now node then we have to say that leprechaun's to do so
on the little assign the node two will return this new node and that note will be assigned to the left
of this node.
So the node three will be assigned to this node for then our tree will be represented, something like
this.
So we are done with this statement that leprechaun's to the project.
Note that left.
Let's call with this note that we have to do the right project.
So this is our current node.
So let's call with this.
Not for a writer.
Wanted it to be here, right.
Wrote it for right rotation.
This is our pseudocode.
This is current and this is new.
Kind of leprechaun's to on the left, we have to assign current one that led to that.
Right.
So on the right of this laptop current is now.
So let's insert here now node and new route dot radicals to code that is for and here will return this
new route.
This new route will be assigned to the left of this node six, when you call it that leprechaun's for
incitement that left with the value.
Then our tree will be represented, something like this.
And we have calculated the height of new node and continued using this formula.
And then it will return this to the left of this node six.
And this is the argument and will return this note to this mean for.
And this is how we can insert a value in a inventory.
This is called Labourite condition for simple deliberation, they have to do a right tradition of,
if understood, left right condition.
This solution takes a lot of time, complexity and lower the expense complexity.
What we have understood is the explanation is understanding this with explanation.
Let us know.
Thanks for watching.
I'll see you in the next video.