Hi, everyone.
So in this video, we are going to learn a new tactic to keep.
So if you remember in the last video we discussed that balanced body was the best option for implementing
ridiculous because the time complexity was in Logan and all other leaders were giving us and skirt time
complexity.
But balanced bisdee has some issues.
So there are some problems with Belen's reused.
So the first problem is basically the balancing factor.
So what we have to do, so we have to write code in such a way that our trees are always balanced.
So this is overhead for us.
Now, the second problem with balanced Vista is basically the storing is very complicated.
So in balance, Misty.
The way you insert the elements, so it is going to be very, very complicated.
So instead of using balanced for implementing vertical, so we have designed a new researcher called
Heap and we will use Hipp for implementing Veridical.
So let us now try to understand, what is he?
First of all, we know he is a researcher, so there are some he properties.
And what are those properties that make it suitable for implementing vertical?
So the first he properties actually it is a complete binary tree.
So he is I think it is just a complete by nutri, in short, we rated CBT complete by CBT, not a second
property is basically it has something called border property, which we will study in some time.
So because of these two properties, he is suitable for implementing VERIDICAL.
So first, now let us discuss what is a complete by Nuti CBT so we all know what is a binary tree by
trees, a tree which will have maksym to jalon zero one or two so maksym a. can have two general in
binary tree.
So let us discuss what is complete by Niddrie so incomplete Minuti, it has only one property sorry
to property, so first properties will be first properties.
All levels are completely full except the last level.
So all levels are completely full except last one.
So consider one example, suppose.
This is a binding treaty, so it's this binary CBT.
Now, this property, so all levels are completely filled except the last level.
So remove the last level now at all levels are filled.
So, yes, it is a CBT.
Now, consider this example.
So is this by nutri acerbity or not?
So if we'll see.
We can't ignore the last level because we can accept the last level, all levels should be completely
full, but this level is not full, you can see.
So this node has a left children, but this node doesn't have children.
So this node, this level is not completely filled.
So that's why this is not a subsidy.
Now, the second property of Sebti is basically we have to fill the levels from left to right, so from
left to right.
So what is the meaning of Left-to-right?
So Nords will be inserted from left to right.
So, for example.
So this is a celebrity.
Perfectly fine.
This is also a celebrity.
Now, is this a acerbity?
So is this a CBD of going by this definition?
You consider this definition to all levels are completely failed at this level is completely.
This level is completely full, but this level is not completely full.
But that is an exception.
So according to this definition, they should be Sebti, but we have to also apply this definition.
So the nodes have to be filled from left to right.
So the meaning is basically.
So this node has a left node, but this node doesn't have a right node, so it should be filled from
left to right.
So this node is missing.
So that's why this is not a CBT.
This is not a CBD.
I'm repeating myself.
This is a city, correct?
Then if you want to insert one more note, you have to insert at the left, because we have to insert
Nordström from left, right.
So this is also a celebrity.
But as soon as you insert this node, if you will insert this note, then it is not a Sebti, right?
This is not a celebrity because you missed this node.
You are missing this node.
We have to insert the node from left to right.
So this is not a celebrity.
Now, let us consider some example.
And now let's try to decide what is a subsidy or which is not CBT.
It is a celebrity.
This is Sebti.
It is also Sabeti again, this is a by Nutri again, this is a computer by Nutri.
This is also a computer by Nutri.
This is also committed by Nutri.
This is also accompanied by Nutri.
This is also committed by the military.
This is also committed by Niddrie.
This is also committed by Nutri.
Now, this is not a celebrity.
This is not a celebrity, so going by the first definition, all levels are completely full except the
last level.
So that's not an issue.
But going by the second definition, you missed the left.
And so I have to fill from left to right.
I have to fill from left, right.
So that's why this note is not there.
So this is not a CBD anymore.
Now, let's take one more example.
Now let's see how we can insert or delete from a CBT.
From a complete.
So this is my complete Pinetree.
Let's take one example.
So.
Now, this is a complete by nutri, all levels are completely full except the last level.
And we are feeling from left to right, so one more thing, when I'm saying all levels are completely
full except the last level.
So that means this is also somebody.
If all levels are filled, that is also CBD.
So this is a CBD, all levels are filled.
Last year also fell.
Now, consider this example, so this is a celebrity because all the levels are filled and we are feeling
from left to right.
So this is a celebrity.
Now I want to insert some nodes.
So, for example, if I want to insert Ben so Ben can be inserted so that this really means somebody.
So the only position available to me is basically this one.
So this is the only position available for inserting then, so that the tree remains CBT complete by
Nutri.
Now I want to Insurgentes.
So the only option available to me is this one.
Now I want to insert, let's say, 25.
So only option available to me is this one.
I want to insert TOTY.
So the only position available to me is this one left of five.
OK, so we are inserting from left to right.
So that mystery remains a complete by Nutri, and I suppose I want to delete some notes.
I want to delete some notes, so can I delete six, so if it will delete node six, this tree is not
Sabitha anymore because this level is not completely filled.
So you cannot delete six.
We cannot delay tax, so can we delay it for no, we cannot lead for it because if we will delay it
for.
OK, so instead of let's make it then, so can we delete them?
No, we cannot let them, because then then this level is not completely full.
So consider this liberty, so this is a complete binary three, four, five and six, so this is complete
by Nutri.
Now tell me which in I can delete.
So that mystery remains a computer by nutri, so I can only delete the last node, which is six, so
deleting means you can only delete the last element of the last level.
You can delete the last element of the last level.
So we can only delete six.
Now, after deleting six, we can only delete five.
So that distri remains a complete binary.
After deleting five, I can delete four after four, for I can only military.
Then I can only do a little and then I can delete one.
So I hope you understood what is the meaning, how we can insert and how we can delete.
So we have to start from left to right and we can delete from right to left.
Simple from the last level, so we will discuss more about complete minidress in our next video, I
will turn the next one, but by.