Hello, everyone, and this listen, we are going to learn a new subject, but I ridicules.
Now for understanding priority, let us take some example, so let us consider this example, flight
reservation system.
So I have a flight reservation system and these five passengers are actually waiting for their bookings
to be confirmed.
Now, the scenario is I have only one seat available.
So the question arises among these five passengers whose ticket we should confirm was booking, we should
confirm.
So they are actually many ways to decide.
So one common technique followed is basically FCF is.
Now in a FCF is what will do, so even came first, so I will give the seat to Putin, not if when most
of it is, then I will give that seat to be do.
If one seat is available, then I will give the seat to Petrie and this will go on.
So on the basis of FCF, we can decide who is boogieing.
We should confirm.
So in FCF, US, what is happening here?
So each passenger actually has a time associated with them, the time at which they booked their tickets.
So everyone has a time associated.
And in this case.
Time is actually a priority factor.
Time is actually a priority factor, so the person having the least priority factor will come first.
I am repeating myself, each passenger actually has a time associated with them, their time at which
they booked their ticket.
So this time factor is actually called a priority factor.
So in FCF, is the person having the least priority?
Welcome first, simple.
Now, the second way of confirming that can be very.
So suppose among these five passengers there is some VIP.
So these five passengers, let's hope, would be to be three before and be five.
So these five passengers are having VIP factor attached to them.
So suppose it has a priority.
It has a VIP factor, too.
It has a VIP factor, five then zero three.
And let's say zero.
So if one seat is available, then that suit will be given two percent to.
Two passenger, Putu, because it is having the highest vape effect that if one was it is available,
then the seat will be given to P1 or let's make the priority factor one so before has done so first.
Once it is available, then the seat will be given to be safe.
Then if one more desirable than B1, then similarly before and let's make it minus one.
So then be five and then be three.
So in this case, what is happening, each passenger is actually having a VIP factor attached to them,
so this VIP factor can be called as a priority factor.
So we are deciding on the basis of priority whose seat we should confirm first.
So FCF is the person having the least priority, least priority means the least time will come out first.
And similarly in VPE, the person having the maximum priority, Maksim Browdy, means the maximum VIP
factor will come out first.
Now, the third way of deciding can be, for example, each factor.
So the person, the passenger having the mixed image will come first.
So suppose there are five passengers, 22 to be three people wouldn't be five and their ages are, let's
say, 18, 20, 60, 30 and 45.
So if one seat is available, then the person having the maximum age will be provided that seat, so
people will come first, then after Putri be five, then before then Putu and then even so, basically
in this age factor.
So this each factor are actually the priority factors.
So in this third problem, the person having the maximum priority, so basically the person having the
maximum age will commit first.
So this is arbitrary and this is P five, so you can understand what we are doing.
So on the basis of priority factors assigned to the passengers, we are ordering them in NTFS.
The person having the least priority will come at first in VIP.
The person having the maximum priority will come at first a.m. in the age factor, the person having
the maximum priority, the maximum it will commit first.
So basically, let us try to understand these passengers are actually elements.
So suppose these passengers are nothing.
So they are basically our elements.
So what is priority?
Q So in priority queue, I need to extract elements in some specific orders.
Now what we are trying to learn here, so we are discussing that I need to extract our elements in some
specific orders so every element has some important factor, has some priority factor attached to them.
And on the basis of priority factors, we're going to start our element.
Simple.
One more time, I'm repeating myself, so consider all these passengers as elements and what do we want?
We want our element to be arranged according to a specific order.
So every element has some priority or importance factor attached to them.
And on the basis of the priority factor, we can start our elements.
Let us consider one more example.
So this time I have hospital management system and I have five passengers, so these are patients,
so I have five patients and only one room is available.
So among these five patients.
Which patient should be provided with dirham?
So, again, there are many ways to decide.
So, again, the first simple way is first come first.
So so if one came first, then Putu, then BTE and similarly, then be five.
So, again, this time also every person has been assigned a time, the time at which they came at the
hospital.
So on the basis of time, so time is nothing.
It is just a priority factor.
So on the basis of priority factor, the person having the patient, having the least priority will
come first, will be provided with the services first.
Now, the second way of deciding can be the criticality factor.
For example, the situation of a patient is critical, so that patient will be served first.
So let us consider five patients and now let us assign the criticality.
So let's say this is 15, 30, 2010 and 100.
So if I have only one room available, then patient B five will be provided with that room.
So first B five and then I have B to then be three, then even N before.
So in this way.
So here, what is the priority factor?
So these these critical defectively, we can also call them as priority factor.
So in this critical fact that the person having the maximum priority, the person having the maximum
critical defector, will be provided with their own first simple.
Now let us discuss what is a priority queue.
So priority kill?
It is nothing.
It is just the extension of normal use.
So we have started use and practical is just an extension to other tools.
So our normal use is basically first in, first out.
So normal does follow this principle, first in, first out, but priority is to protect the normal
use.
You can insert the element, we will insert the element at the end at the rear position, but if you
want to access the elements, so element will come out on the basis of the parity.
I'm repeating myself.
In private schools.
You can insert the element, no doubt, but if you want to access the element so the elements will come
out on the basis of their Baruti.
So let us have an example.
So suppose this is my priority queue.
And let's say the element then come first, so then here, then element during the game, so 20, then
element five, game five, then element six.
So six.
And then element one.
So let's say I am deciding clarity, so I am assigning priority, for example, element then has a priority
of often Element 20 has a priority of 20, and similarly, Element five has a priority, five elements.
Six has a priority of sex and element one has a priority of one.
So then you will try to exhaust the elements so elements will come out on the basis of their parity.
So the element having the maximum priority will come first.
So 20 is having the maximum priority.
So first they will come, then 10 will come.
Then six, then five and then one.
OK, so this is the meaning of priority queue, so priority means the elements will come out of the
priority queue according to their priorities, to the element having the maximum priority will come
first.
And similarly, this will go on.
So I hope you understood the priority now priority you can be of two types, mindblower dequeue and
makes priority queue.
So you can be of two types.
The veridical.
And the second one is basically makes you.
Now, what is the difference between men and make some practical so in particular the element having
the least priority will come first in the mix, in particular the element having the highest priority
will come first.
So, for example, so this is the example of a maximum priority queue because the element having the
maximum priority is coming out first.
So if this is our minimum priority, if this is impractical, then the element having the least parity
will come first.
So just opposite of this.
One has the least party, so it will come first, then five, then six, then 10 and then 20, so minimum
and make implied they are opposite of each other.
So it makes introduces the element.
Having the maximum priority will come.
First priority produces the element, having the minimum priority will come first.
Simple.
So these are the two types of protocols.
Now let us discuss the functions that we need in our priority queue.
So basically we need three functions.
So first function is we need insert function.
The second function we need is basically get Max in case of maximum priority and in case of medium priority,
I will have a function, get a minimum, get max element to get minimum element.
Now, the third function that we need is basically remove maximum element in case of mixing protocol.
And in case of minimum priority queue, we need the function, remove minimum element.
So these three functions.
Should be pleasant, you know, but I would argue now in the next video, we will discuss ways of implementing
Veridical.
I will see you in the next one.
Bye bye.