Hello, everyone.
So in the last video, I gave this question to you, you have to construct the mediumship and these
are the elements.
And then after constructing the minimum heap, you have to perform this, remove minimum function,
you have to apply this removing and function twice.
So now let's start discussing our solution.
So minimum, keep the properties very simple.
So raw data should be less then left value and raw data should also be less than the right value Raychelle
value.
So now let's start discussing the solution.
So the first element is still Sawtell then six.
So the six will go in the left hand side, then compare six and 12.
So 12 will come here and six will come here.
Now the next element is five.
So five will go in this direction.
Now compare five and six.
So again we have to do swapping so six will come here and five will come here.
Now the next element is hundred, so one that will go in this direction.
Now the next element is one.
So one will go.
One will go in this direction.
So compared to 11, again, we have to do something.
So 12 will come here.
When will come here?
Now compare one and five.
So again, you have to do something.
So five will come here and one will come here.
Now the next element is nine.
So nine will go in this direction.
So nine and six.
So it is correct.
Now the next element is zero.
So zero will go in this direction now compared to zero and six.
So you have to do swapping six will come here and zero will come here now compared to zero and one.
So again, you have to do something.
One will come here.
Zero will come here.
Now the next element is 14.
So 14 will go in this direction.
Now compare 14 and under.
So again, you have to do something and it will come here and 14 will come here.
Now compare 14 and five.
So it is correct.
So finally, what is our minimum here?
So this is zero and then we have five.
So here we have one.
So here we have nine and six.
So here we have 14, then we have 12, and then we have 100, so this is our final solution.
Now let's verify.
So the smallest element, we are constructing them.
So the smallest element should be at the top.
That is correct.
Now, Jack, with a complete binary tree.
So this is a complete binary.
Now, a check for the minimum property.
So zero is less than five and one.
Correct.
So five is listed in 14 and 12.
Correct.
14 is listed under the correct.
One is less than nine and six.
Correct.
So this is our correct minimum heap.
Now what we have to do, so we have to remove the minimum element.
So basically I have to remove the element zero.
Again, the formula, the the rules are very simple.
It will slap.
And handler, basically, you have to establish topmost element with the last element, so zero will
come here and it will come here and then you will delete the element zero.
And then what they have to do, so you have to perform down, help you fight operation, so compared
with five and one, so one is a smaller one.
So compared to a step, one 800, 200 will come here and one will come here.
Now, compare that with nine and six.
So six is the smallest.
So strap so 100 will come here and six will come here now after one remove minimum operation.
What is our military what is our minimum help?
So this is one then I have five here.
I have six here, so I have 14 and I have 12.
I have nine.
And then I have 100.
So again, you can see the minimum element when is the minimum element?
And it is at the top.
So, again, we have to apply the remove minimum function.
So we will do the same operation again.
So strap with the last element.
So what will come here and one hundred will come here.
Now you can delete the last element, you can delete the remote minimum element.
So now we have to do we have to perform down here before so compared with five and six.
So five for the smallest.
So five will come here and 100 will come here.
Now among 14 and 12, so 12 is the smallest.
So SUDEP.
So 12 will come here and it will come here.
So finally, what is our three?
So this is our output five, then I have well, so I have six here, then I have 14 here, then I have
100 here and then I have nine here.
So this is our final output.
You can compare your minimum with my help and you can check whether the solution is correct or wrong.
So this is the correct solution.
Now, let us also take one example for the maximum hip so that our concepts become strong.
So now what we want to do, I want to construct maximum hip, hip.
And let's say that elements are, let's say fifteen to twenty nine, let's say zero and 100.
So what is the property for the maximum hip.
So rude value should be greater than the left value and it should be bigger than the right value.
So now let's start.
Now, let's start our discussion.
So first element, ultrafine 15, then the element is two, so two will go in the left hand side now
compared to 15 is then to correct.
Now, 20 or 20 will go in this direction.
Now, what do you have to do?
So you have to perform strapping Grantville come here and 15 will come here.
Now the next element is nine so nine will go ahead.
Now compare to two and nine again.
You have to do stepping so two will come here and nine will compare now nine and 20.
So it is correct.
Now the next element is zero.
So zero will come here.
It is correct.
Now the next element is 100.
200 will come here.
Now compare hundred and fifteen.
So you have to perform stepping.
Now compare hundred and twenty, so again, you have to do sweepings or 20 will come here and hundreds
will come here.
Now, what is my maximum here?
So this is 100.
Then we have nine here we have 20, and then we have two, so here we have zero and then we have 15
now contiguously.
So first of all, this is a complete by nutri.
Now let's check for the Mexi property.
So 100 is greater than nine and 20, correct.
20 is greater than 15, correct.
Nine is according to one zero.
Correct.
So this is our correct mix up.
Now, let us now in this mix up, so in this mix tape, you can see the largest element is under.
So I notice the largest element and the largest element is BESANT at the topmost position, the root
element.
So if you want to call the function, let's get maximum element, what you have to do.
So you just have to retain the element root to the time complexities.
Big of one.
Now, suppose you want to remove Maxim element, so you want to call the function, remove maximum.
So, again, we have to do the same operation.
What they have to do, so I have to compare, I have to separate the element and the last element,
15, so 15 will come here and 100 will come here, and then you can delete the element under the MAKSYM
element and then what you have to do.
So you have to perform down here.
If I compare 15 with the 1920s or 20s, the largest, so swaby 20, so 15 will come here and 20 will
come here.
Now, again, compare 15, so it is correct, we do not have to compare anything.
So finally, what is my binary after Werrimull maximum?
So this is 20, then we have nine, then we have 15, and then we have two, and then we have zero.
So again, you can see the maximum element is always present at the top position.
So mean maximum also remove maximum is log of N down here biffy and.
The insert function is also logoff end up pretty simple.
Now, if you want to perform one more time, if you want to do swapping one more time.
So if you want to remove the MAKSYM element one more time, what you will do again, 20 and zero.
So zero will come here and they will come here.
And then you can remove the last element now jike zero with the nine and 15.
So 15 is the largest, so zero will come here and 15 will come here and we are done.
So finally our maximum.
He is 15, then we have nine here and then we have zero here and then we have 22 here.
So finally, the largest element is present at the top and this is a complete binary and this is also
a maximum.
Hipp So 15 is greater than nine and zero.
Nine is lower than two.
So that's how all these things are working.
So from the next video, we will start implementing our own protocol using hybrid structure.
I will see you in the next one by.