Hi, everyone.
So starting from this video, we will implement our own triadic you using the Hebrew Dastagir.
So what functions do we need?
So we need one insert function.
The second function that we need is actually the remove function.
For example, if I were implementing meaning prior to Q so I need the function removed minimum.
Now, the terror function, I need to get the minimum function if I'm implementing minimum prior to
the food function that we need is let's say is empty, is my priority empty?
So is empty function.
And the fifth function, let's say we want Getz's.
So how many elements are present in my prior dequeue and as discussed?
We need a complete binary tree, so we will install the computer by Niddrie in an eddy.
So we need an array to store our computer by.
We do not have to construct manually, so there's no point as required.
We will just store our completed by Nutri in our area.
So we will do whatever complete binary tree in an eddy.
And instead of using an array, we will use vectors because vectors are much more powerful than Ediz.
So now let's start implementing our priority.
Giclas.
So glassblower dequeue.
So what do we need so we need an array to store whatever complete binary tree, so let's take a vector
instead of the that.
Just so I want to start I want to create protegé of integers.
And let's say the name is Piku.
So this is private and now let us write some functions inside public, so first of all, the first function
is going to be a constructor.
So let's say it is the default constructor.
So for now, let's leave it empty.
We will discuss it later.
If we have to do something about it, then let us implement.
Our first function is empty function.
So I will be the name of the function is is empty.
So what is functionally done so it will return to Werfel's, whether my priority is empathy or not?
So this is my priority queue BQ, so be good size.
And I will check if it is equal to zero, then return to their downfalls.
So what I'm doing here.
So this size function is actually the function of vectors, so I'm using the same function to get the
size of my vector and then I am checking if it is zero return true otherwise are done false.
So, for example, if my representatives are, what will happen?
Zero equals equals zero.
So this condition is true.
So I'm going to return.
True.
Now let's say if a vector is not empty, let's say it is containing five elements.
So five equals equals zero.
Now this condition is false.
So I'm going to return false.
Now this again.
So this function is in function of this vector class and we have already started vector class in detail.
So is employee function will work fine.
So now let us write one more function gets a function so that it will be integer getz's.
Now, what does good sales function will return, so it will return how many elements are present inside
my Bowdich you?
So basically it will return the size of our priority to.
What we can say, the total number of elements present.
Now, Gert's dysfunction, so what it will done so I can likely use this as a function of vector glass,
so I will return, be good to use simple.
So again, this size function is a function of our vector class.
Now, these two functions are very, very simple.
Now let us implement one more function.
Get the minimum.
So get minimum, but it will return to wavefunction, get minimum.
It will obviously you've done it, Egypt, now I'm implementing minimum priority queue, so what I'm
doing, I am implementing the minimum priority queue.
Now, in the media in particular, let us take an example.
So let's take this example.
So this is a minimum priority.
So this is a minimum heap and how we restore hope in our vector in our area.
So this is one, two, three, and then four.
And then five.
So when is the minimum element?
So when I call the function at the minimum, it should be done one.
So there is one present.
So when we present at the next zero, so one is present at the next room, so I will return the element
to present at the next zero.
So one more time I'm implementing the minimum priority.
That's why I am writing the minimum function.
So what it will return, it will return the element presented 026 now, is this correct?
So is this guy at the minimum function, correct?
No, this is not correct, because what if my priority was empty?
So what if they are a zero element inside my priority queue?
So first, before returning the zero element, you should check whether pretty good and pretty or not.
So how to check.
So I have written this function is empty, so let's copy this.
So I will call this function is empty, so if the function returns true, that means my priority is
empty.
So I can return our default value.
Let's say I am returning zero because we have to return an integer.
So that's why I have to return something.
So let's say I'm returning zero.
So here's zero signifies that my birthday is actually empty.
So we have implemented three functions, three very small, small functions we have implemented good
function is empty function, gateman function.
Now we have to implement insert function and remove minimum function.
So I will discuss these two functions in our next video.
And if you want, you can also implement you can also try to implement these two functions yourself.
That will be a very good practice.
So I will discuss the solution.
I will write the code for the insert and the momentum in the next video.
So I will see you there.
Bye.