1
00:00:01,770 --> 00:00:06,330
Hello, everyone, and this listen, we are going to learn a new subject, but I ridicules.

2
00:00:07,890 --> 00:00:13,060
Now for understanding priority, let us take some example, so let us consider this example, flight

3
00:00:13,060 --> 00:00:13,940
reservation system.

4
00:00:14,370 --> 00:00:20,460
So I have a flight reservation system and these five passengers are actually waiting for their bookings

5
00:00:20,460 --> 00:00:21,240
to be confirmed.

6
00:00:21,990 --> 00:00:24,950
Now, the scenario is I have only one seat available.

7
00:00:25,590 --> 00:00:31,770
So the question arises among these five passengers whose ticket we should confirm was booking, we should

8
00:00:31,770 --> 00:00:32,250
confirm.

9
00:00:32,850 --> 00:00:34,710
So they are actually many ways to decide.

10
00:00:35,160 --> 00:00:38,570
So one common technique followed is basically FCF is.

11
00:00:40,480 --> 00:00:47,080
Now in a FCF is what will do, so even came first, so I will give the seat to Putin, not if when most

12
00:00:47,090 --> 00:00:49,870
of it is, then I will give that seat to be do.

13
00:00:50,230 --> 00:00:55,440
If one seat is available, then I will give the seat to Petrie and this will go on.

14
00:00:55,780 --> 00:00:59,410
So on the basis of FCF, we can decide who is boogieing.

15
00:00:59,410 --> 00:01:00,220
We should confirm.

16
00:01:01,600 --> 00:01:04,790
So in FCF, US, what is happening here?

17
00:01:04,959 --> 00:01:11,770
So each passenger actually has a time associated with them, the time at which they booked their tickets.

18
00:01:12,310 --> 00:01:14,830
So everyone has a time associated.

19
00:01:17,330 --> 00:01:18,620
And in this case.

20
00:01:19,950 --> 00:01:21,990
Time is actually a priority factor.

21
00:01:23,430 --> 00:01:30,000
Time is actually a priority factor, so the person having the least priority factor will come first.

22
00:01:30,920 --> 00:01:37,020
I am repeating myself, each passenger actually has a time associated with them, their time at which

23
00:01:37,020 --> 00:01:38,150
they booked their ticket.

24
00:01:38,640 --> 00:01:41,640
So this time factor is actually called a priority factor.

25
00:01:42,450 --> 00:01:46,290
So in FCF, is the person having the least priority?

26
00:01:47,550 --> 00:01:49,380
Welcome first, simple.

27
00:01:50,350 --> 00:01:53,810
Now, the second way of confirming that can be very.

28
00:01:55,210 --> 00:01:58,940
So suppose among these five passengers there is some VIP.

29
00:01:59,470 --> 00:02:04,640
So these five passengers, let's hope, would be to be three before and be five.

30
00:02:04,960 --> 00:02:08,880
So these five passengers are having VIP factor attached to them.

31
00:02:08,889 --> 00:02:10,630
So suppose it has a priority.

32
00:02:11,020 --> 00:02:12,260
It has a VIP factor, too.

33
00:02:12,640 --> 00:02:15,730
It has a VIP factor, five then zero three.

34
00:02:16,000 --> 00:02:16,900
And let's say zero.

35
00:02:18,080 --> 00:02:22,850
So if one seat is available, then that suit will be given two percent to.

36
00:02:23,830 --> 00:02:30,010
Two passenger, Putu, because it is having the highest vape effect that if one was it is available,

37
00:02:30,010 --> 00:02:37,750
then the seat will be given to P1 or let's make the priority factor one so before has done so first.

38
00:02:37,940 --> 00:02:41,770
Once it is available, then the seat will be given to be safe.

39
00:02:41,950 --> 00:02:47,740
Then if one more desirable than B1, then similarly before and let's make it minus one.

40
00:02:47,740 --> 00:02:50,020
So then be five and then be three.

41
00:02:51,520 --> 00:02:58,590
So in this case, what is happening, each passenger is actually having a VIP factor attached to them,

42
00:02:58,990 --> 00:03:02,330
so this VIP factor can be called as a priority factor.

43
00:03:02,680 --> 00:03:07,750
So we are deciding on the basis of priority whose seat we should confirm first.

44
00:03:08,970 --> 00:03:16,880
So FCF is the person having the least priority, least priority means the least time will come out first.

45
00:03:16,890 --> 00:03:22,530
And similarly in VPE, the person having the maximum priority, Maksim Browdy, means the maximum VIP

46
00:03:22,530 --> 00:03:24,180
factor will come out first.

47
00:03:25,440 --> 00:03:29,490
Now, the third way of deciding can be, for example, each factor.

48
00:03:31,160 --> 00:03:35,760
So the person, the passenger having the mixed image will come first.

49
00:03:35,780 --> 00:03:42,410
So suppose there are five passengers, 22 to be three people wouldn't be five and their ages are, let's

50
00:03:42,410 --> 00:03:46,670
say, 18, 20, 60, 30 and 45.

51
00:03:48,800 --> 00:03:55,440
So if one seat is available, then the person having the maximum age will be provided that seat, so

52
00:03:55,440 --> 00:04:05,060
people will come first, then after Putri be five, then before then Putu and then even so, basically

53
00:04:05,450 --> 00:04:06,870
in this age factor.

54
00:04:07,730 --> 00:04:11,560
So this each factor are actually the priority factors.

55
00:04:11,990 --> 00:04:19,519
So in this third problem, the person having the maximum priority, so basically the person having the

56
00:04:19,519 --> 00:04:21,370
maximum age will commit first.

57
00:04:22,100 --> 00:04:27,170
So this is arbitrary and this is P five, so you can understand what we are doing.

58
00:04:27,170 --> 00:04:34,530
So on the basis of priority factors assigned to the passengers, we are ordering them in NTFS.

59
00:04:34,550 --> 00:04:38,050
The person having the least priority will come at first in VIP.

60
00:04:38,330 --> 00:04:43,160
The person having the maximum priority will come at first a.m. in the age factor, the person having

61
00:04:43,160 --> 00:04:45,790
the maximum priority, the maximum it will commit first.

62
00:04:47,030 --> 00:04:51,650
So basically, let us try to understand these passengers are actually elements.

63
00:04:52,280 --> 00:04:55,390
So suppose these passengers are nothing.

64
00:04:55,910 --> 00:04:58,440
So they are basically our elements.

65
00:04:59,330 --> 00:05:00,340
So what is priority?

66
00:05:00,360 --> 00:05:05,890
Q So in priority queue, I need to extract elements in some specific orders.

67
00:05:07,250 --> 00:05:13,340
Now what we are trying to learn here, so we are discussing that I need to extract our elements in some

68
00:05:13,340 --> 00:05:20,750
specific orders so every element has some important factor, has some priority factor attached to them.

69
00:05:20,750 --> 00:05:24,250
And on the basis of priority factors, we're going to start our element.

70
00:05:24,920 --> 00:05:25,460
Simple.

71
00:05:26,380 --> 00:05:32,750
One more time, I'm repeating myself, so consider all these passengers as elements and what do we want?

72
00:05:33,100 --> 00:05:36,880
We want our element to be arranged according to a specific order.

73
00:05:37,750 --> 00:05:42,040
So every element has some priority or importance factor attached to them.

74
00:05:42,220 --> 00:05:46,360
And on the basis of the priority factor, we can start our elements.

75
00:05:47,250 --> 00:05:48,940
Let us consider one more example.

76
00:05:50,880 --> 00:05:57,510
So this time I have hospital management system and I have five passengers, so these are patients,

77
00:05:57,810 --> 00:06:01,220
so I have five patients and only one room is available.

78
00:06:03,120 --> 00:06:04,980
So among these five patients.

79
00:06:06,660 --> 00:06:08,550
Which patient should be provided with dirham?

80
00:06:09,750 --> 00:06:11,650
So, again, there are many ways to decide.

81
00:06:12,090 --> 00:06:15,250
So, again, the first simple way is first come first.

82
00:06:15,290 --> 00:06:22,620
So so if one came first, then Putu, then BTE and similarly, then be five.

83
00:06:27,000 --> 00:06:33,810
So, again, this time also every person has been assigned a time, the time at which they came at the

84
00:06:33,810 --> 00:06:34,380
hospital.

85
00:06:34,650 --> 00:06:36,820
So on the basis of time, so time is nothing.

86
00:06:36,840 --> 00:06:38,410
It is just a priority factor.

87
00:06:38,610 --> 00:06:43,620
So on the basis of priority factor, the person having the patient, having the least priority will

88
00:06:43,620 --> 00:06:46,070
come first, will be provided with the services first.

89
00:06:47,160 --> 00:06:50,130
Now, the second way of deciding can be the criticality factor.

90
00:06:52,770 --> 00:06:57,400
For example, the situation of a patient is critical, so that patient will be served first.

91
00:06:57,750 --> 00:07:03,420
So let us consider five patients and now let us assign the criticality.

92
00:07:03,790 --> 00:07:08,990
So let's say this is 15, 30, 2010 and 100.

93
00:07:09,900 --> 00:07:15,900
So if I have only one room available, then patient B five will be provided with that room.

94
00:07:16,380 --> 00:07:23,220
So first B five and then I have B to then be three, then even N before.

95
00:07:23,730 --> 00:07:24,570
So in this way.

96
00:07:26,030 --> 00:07:28,620
So here, what is the priority factor?

97
00:07:29,000 --> 00:07:34,670
So these these critical defectively, we can also call them as priority factor.

98
00:07:35,760 --> 00:07:41,820
So in this critical fact that the person having the maximum priority, the person having the maximum

99
00:07:41,820 --> 00:07:45,400
critical defector, will be provided with their own first simple.

100
00:07:46,050 --> 00:07:49,080
Now let us discuss what is a priority queue.

101
00:07:49,620 --> 00:07:50,590
So priority kill?

102
00:07:50,610 --> 00:07:51,200
It is nothing.

103
00:07:51,210 --> 00:07:53,720
It is just the extension of normal use.

104
00:07:54,450 --> 00:07:59,430
So we have started use and practical is just an extension to other tools.

105
00:08:00,420 --> 00:08:04,920
So our normal use is basically first in, first out.

106
00:08:05,130 --> 00:08:13,140
So normal does follow this principle, first in, first out, but priority is to protect the normal

107
00:08:13,140 --> 00:08:13,470
use.

108
00:08:15,920 --> 00:08:23,090
You can insert the element, we will insert the element at the end at the rear position, but if you

109
00:08:23,090 --> 00:08:27,790
want to access the elements, so element will come out on the basis of the parity.

110
00:08:28,760 --> 00:08:29,890
I'm repeating myself.

111
00:08:31,980 --> 00:08:33,120
In private schools.

112
00:08:34,120 --> 00:08:40,659
You can insert the element, no doubt, but if you want to access the element so the elements will come

113
00:08:40,659 --> 00:08:42,400
out on the basis of their Baruti.

114
00:08:43,270 --> 00:08:44,940
So let us have an example.

115
00:08:44,950 --> 00:08:47,140
So suppose this is my priority queue.

116
00:08:49,570 --> 00:08:56,260
And let's say the element then come first, so then here, then element during the game, so 20, then

117
00:08:56,260 --> 00:08:59,630
element five, game five, then element six.

118
00:09:00,010 --> 00:09:00,640
So six.

119
00:09:00,640 --> 00:09:01,900
And then element one.

120
00:09:04,190 --> 00:09:11,330
So let's say I am deciding clarity, so I am assigning priority, for example, element then has a priority

121
00:09:11,330 --> 00:09:17,420
of often Element 20 has a priority of 20, and similarly, Element five has a priority, five elements.

122
00:09:17,420 --> 00:09:21,460
Six has a priority of sex and element one has a priority of one.

123
00:09:22,490 --> 00:09:29,270
So then you will try to exhaust the elements so elements will come out on the basis of their parity.

124
00:09:29,540 --> 00:09:32,110
So the element having the maximum priority will come first.

125
00:09:32,480 --> 00:09:34,660
So 20 is having the maximum priority.

126
00:09:34,670 --> 00:09:37,700
So first they will come, then 10 will come.

127
00:09:39,160 --> 00:09:43,660
Then six, then five and then one.

128
00:09:44,680 --> 00:09:50,380
OK, so this is the meaning of priority queue, so priority means the elements will come out of the

129
00:09:50,380 --> 00:09:55,930
priority queue according to their priorities, to the element having the maximum priority will come

130
00:09:55,930 --> 00:09:56,320
first.

131
00:09:56,770 --> 00:09:58,720
And similarly, this will go on.

132
00:09:59,260 --> 00:10:04,570
So I hope you understood the priority now priority you can be of two types, mindblower dequeue and

133
00:10:04,570 --> 00:10:05,560
makes priority queue.

134
00:10:07,030 --> 00:10:08,980
So you can be of two types.

135
00:10:10,020 --> 00:10:11,310
The veridical.

136
00:10:13,430 --> 00:10:16,730
And the second one is basically makes you.

137
00:10:18,200 --> 00:10:25,850
Now, what is the difference between men and make some practical so in particular the element having

138
00:10:25,850 --> 00:10:32,270
the least priority will come first in the mix, in particular the element having the highest priority

139
00:10:32,270 --> 00:10:33,030
will come first.

140
00:10:34,040 --> 00:10:40,790
So, for example, so this is the example of a maximum priority queue because the element having the

141
00:10:40,790 --> 00:10:42,870
maximum priority is coming out first.

142
00:10:43,340 --> 00:10:49,160
So if this is our minimum priority, if this is impractical, then the element having the least parity

143
00:10:49,160 --> 00:10:49,790
will come first.

144
00:10:49,820 --> 00:10:51,230
So just opposite of this.

145
00:10:52,390 --> 00:11:00,100
One has the least party, so it will come first, then five, then six, then 10 and then 20, so minimum

146
00:11:00,100 --> 00:11:02,490
and make implied they are opposite of each other.

147
00:11:02,950 --> 00:11:04,990
So it makes introduces the element.

148
00:11:04,990 --> 00:11:06,520
Having the maximum priority will come.

149
00:11:06,520 --> 00:11:11,850
First priority produces the element, having the minimum priority will come first.

150
00:11:12,220 --> 00:11:12,750
Simple.

151
00:11:13,540 --> 00:11:15,410
So these are the two types of protocols.

152
00:11:16,310 --> 00:11:19,770
Now let us discuss the functions that we need in our priority queue.

153
00:11:20,620 --> 00:11:22,870
So basically we need three functions.

154
00:11:23,260 --> 00:11:26,200
So first function is we need insert function.

155
00:11:28,510 --> 00:11:36,570
The second function we need is basically get Max in case of maximum priority and in case of medium priority,

156
00:11:36,580 --> 00:11:41,110
I will have a function, get a minimum, get max element to get minimum element.

157
00:11:41,440 --> 00:11:48,960
Now, the third function that we need is basically remove maximum element in case of mixing protocol.

158
00:11:49,270 --> 00:11:53,590
And in case of minimum priority queue, we need the function, remove minimum element.

159
00:11:54,820 --> 00:11:56,140
So these three functions.

160
00:11:57,740 --> 00:12:03,490
Should be pleasant, you know, but I would argue now in the next video, we will discuss ways of implementing

161
00:12:03,500 --> 00:12:04,250
Veridical.

162
00:12:04,610 --> 00:12:05,760
I will see you in the next one.

163
00:12:05,870 --> 00:12:06,290
Bye bye.

