1
00:00:02,000 --> 00:00:02,810
Hi, everyone.

2
00:00:02,840 --> 00:00:08,480
So in this video, what we will do, we will write the code for this much heart function and we will

3
00:00:08,480 --> 00:00:10,230
write the code for Mojada function.

4
00:00:10,550 --> 00:00:12,220
So let's discuss about thought.

5
00:00:12,590 --> 00:00:14,120
So the approach is very simple.

6
00:00:15,900 --> 00:00:23,280
This is a you know, the starting index, you know, the index, so we know starting, we know and we

7
00:00:23,280 --> 00:00:23,880
will find out.

8
00:00:25,980 --> 00:00:27,570
So it will be a start plus.

9
00:00:27,570 --> 00:00:31,100
And by doing so, we'll create another X.

10
00:00:32,840 --> 00:00:34,500
And we will copy all these elements.

11
00:00:35,150 --> 00:00:37,750
So let's do let's write the code for this much.

12
00:00:39,590 --> 00:00:42,320
So what we need to do, first of all, we need to find out the mid.

13
00:00:45,270 --> 00:00:52,710
So let's start by doing so after finding out mood, we will create and ATX.

14
00:00:54,480 --> 00:01:03,360
Let's say the site is held and we need to copy the elements, so I equals zero, I lost an order custommade

15
00:01:03,840 --> 00:01:04,860
I placeless.

16
00:01:06,450 --> 00:01:16,890
So Zulfi is sort of a symbol, so what we are doing, so this is murder, somebody will be here.

17
00:01:18,350 --> 00:01:19,650
And this is our start.

18
00:01:20,060 --> 00:01:23,100
So we copied all these elements in.

19
00:01:23,990 --> 00:01:28,050
OK, so now what we need to do, we will create another area.

20
00:01:28,640 --> 00:01:30,020
Let's create another area.

21
00:01:31,430 --> 00:01:33,890
And what I'm planning to do is I will.

22
00:01:34,070 --> 00:01:35,070
So this is my area.

23
00:01:35,300 --> 00:01:36,320
If this is my area, I.

24
00:01:38,270 --> 00:01:43,790
So I will copy the elements here, I will copy the elements here, and I will not copy the elements

25
00:01:43,790 --> 00:01:44,580
at the beginning.

26
00:01:45,020 --> 00:01:48,180
OK, so I will copy the elements at this position.

27
00:01:49,280 --> 00:01:57,140
So basically what I want to say is if this is my area one, two, three, four, five and six, what

28
00:01:57,140 --> 00:01:57,740
I want to do.

29
00:01:59,440 --> 00:02:08,199
So my ex said, this is my Addicks, this is Arrietty, this is my Eriks, so for Eriks, I'm copying

30
00:02:08,199 --> 00:02:09,550
the elements like this.

31
00:02:09,979 --> 00:02:11,500
OK, one, two and three.

32
00:02:11,620 --> 00:02:17,710
You can see I and I, so basically is Aasim and this is our Ariva.

33
00:02:19,690 --> 00:02:22,780
So I'm copying my elements like this for will come here.

34
00:02:24,090 --> 00:02:27,070
Five will come here and six will come here.

35
00:02:27,090 --> 00:02:28,710
Basically, these values are garbage.

36
00:02:28,750 --> 00:02:30,420
OK, these are garbage.

37
00:02:30,600 --> 00:02:35,040
So basically index will remain so for this president, let's say zero, one, two and three.

38
00:02:35,220 --> 00:02:36,800
So for the next three.

39
00:02:37,020 --> 00:02:39,840
So Environmental four will be present at the next three.

40
00:02:40,290 --> 00:02:40,830
Simple.

41
00:02:43,780 --> 00:02:50,350
So let's we need to create one more ready very let's say the site is under and we need to copy the elements.

42
00:02:53,340 --> 00:03:00,000
So I will start copy from the one so I left tonight request to end I placeless.

43
00:03:01,620 --> 00:03:06,420
So why Yoffie is it goes to a very simple.

44
00:03:07,470 --> 00:03:09,930
So what I'm doing here is see.

45
00:03:14,060 --> 00:03:22,160
This is so starting and this is a middle class, and so this element has an X plus one, so I will start

46
00:03:22,160 --> 00:03:24,460
copy from my next meal plus one till the end.

47
00:03:25,280 --> 00:03:29,150
So this is my plus one index and we will copy all these elements.

48
00:03:29,360 --> 00:03:31,240
And the index is the same IRONI.

49
00:03:31,400 --> 00:03:34,990
So that's why four will be here, five will be here and six will be here.

50
00:03:35,180 --> 00:03:40,190
So if you do not like this approach vertical, so you can put four, five and six here also what do

51
00:03:40,200 --> 00:03:41,740
you do to do right here.

52
00:03:41,760 --> 00:03:44,660
Something like so you tried something like this.

53
00:03:44,660 --> 00:03:54,940
I minus mid minus one I think so if the value of this only plus if the value of it is made a plus one.

54
00:03:55,430 --> 00:03:59,840
So value if I use made plus one and minus plus one.

55
00:03:59,840 --> 00:04:01,610
So that will be present at the next zero.

56
00:04:01,670 --> 00:04:07,040
OK, so if you do not like this approach, if you do not want to copied elements like this, if you

57
00:04:07,040 --> 00:04:11,530
want to add elements to be at the present at the first patrician's.

58
00:04:11,570 --> 00:04:18,649
So four, five and six so you can use this i.e. minus made of minus one equals if you can use any of

59
00:04:18,649 --> 00:04:18,880
them.

60
00:04:18,890 --> 00:04:20,040
OK, it's your choice.

61
00:04:21,920 --> 00:04:28,220
So now I have to add is really X and Y, so I have to whereas ready X and Y, what you need to do,

62
00:04:28,220 --> 00:04:30,320
we need to call the regression on these two areas.

63
00:04:30,320 --> 00:04:32,480
We need to apply my on these two areas.

64
00:04:35,000 --> 00:04:38,180
So let's apply the Mozart, let's copy Mozart.

65
00:04:40,380 --> 00:04:44,730
Muttered Ex, starting and made.

66
00:04:46,500 --> 00:04:55,100
My thought is why starting is middle one and snowboarder's has been sorted.

67
00:04:56,880 --> 00:04:57,750
So what will happen?

68
00:04:59,670 --> 00:05:00,910
So what is the situation right now?

69
00:05:01,260 --> 00:05:05,800
So this area, so it is already sorted and let's take another area.

70
00:05:08,250 --> 00:05:12,060
So if this is already seven, three, one, five, six and two.

71
00:05:15,360 --> 00:05:21,590
So Erich's is basically 71, so after playing them, I thought on this.

72
00:05:21,900 --> 00:05:23,330
Now this area has been sorted.

73
00:05:23,610 --> 00:05:32,910
So basically X-rays one, three and seven simple and decide if I was five, six and two starting points

74
00:05:33,390 --> 00:05:34,840
are containing garbage value.

75
00:05:34,970 --> 00:05:36,260
This is five, six and two.

76
00:05:37,230 --> 00:05:37,890
This is why.

77
00:05:39,120 --> 00:05:41,490
And what they are doing, you got to playing them much harder.

78
00:05:41,610 --> 00:05:48,120
So this area has now been sorted to starting position are empty and this will become two, five and

79
00:05:48,120 --> 00:05:48,480
six.

80
00:05:49,200 --> 00:05:51,420
So this position is basically middle plus one.

81
00:05:52,520 --> 00:05:57,230
This is the starting position and this is the middle position and this is the of position.

82
00:05:57,560 --> 00:06:00,330
So now Exodus started, Aviad is sorted.

83
00:06:00,680 --> 00:06:01,510
So what do.

84
00:06:02,700 --> 00:06:04,290
We will call this function, Marjorie.

85
00:06:04,320 --> 00:06:06,540
We will give every expert, we give everybody.

86
00:06:07,430 --> 00:06:11,070
We will give away and we will give you starting next.

87
00:06:11,070 --> 00:06:12,380
We will give the index.

88
00:06:13,620 --> 00:06:16,890
So let's write the code for the Mercedes.

89
00:06:23,350 --> 00:06:24,160
So what do we do?

90
00:06:24,400 --> 00:06:27,100
Let's call the function Margery's.

91
00:06:32,600 --> 00:06:39,650
So I will give X, which is the area which is ordered area which which need to be sorted, starting

92
00:06:39,650 --> 00:06:40,820
index and index.

93
00:06:41,870 --> 00:06:44,670
And now let us write the code for the majority function.

94
00:06:44,840 --> 00:06:46,820
So how we can write the code for Margery's.

95
00:06:48,050 --> 00:06:55,180
So what we will do I will compare this element one with element to which on is smaller, one is smaller,

96
00:06:55,190 --> 00:06:56,060
so I will put one.

97
00:06:56,420 --> 00:06:59,180
So basically, let's take variables, let's take a variable.

98
00:06:59,180 --> 00:07:02,060
I add this index and let's take a variable JRD index.

99
00:07:02,420 --> 00:07:05,380
So I will move in this direction, will move in this direction.

100
00:07:05,840 --> 00:07:08,420
So let's take variable, let's take two variables.

101
00:07:08,420 --> 00:07:12,230
And so let's find out the first.

102
00:07:13,610 --> 00:07:15,380
So let's start listening to.

103
00:07:17,630 --> 00:07:19,360
Start lessened by.

104
00:07:20,480 --> 00:07:22,670
So what is I.

105
00:07:23,090 --> 00:07:28,370
So I start and what is Jay so Jay's made plus one.

106
00:07:31,780 --> 00:07:41,650
So what I'm doing so this is I I to start and this is Jay, so Jay Z metabolism, so Jay Z metabolism.

107
00:07:41,920 --> 00:07:43,450
So I will move in this direction.

108
00:07:43,450 --> 00:07:46,450
Jay will move in this direction, which will be smaller.

109
00:07:46,460 --> 00:07:47,280
So one is smaller.

110
00:07:47,290 --> 00:07:53,110
So I will put one and I will move forward similarly then I will come back you and also to smaller I

111
00:07:53,110 --> 00:07:55,330
will put two and Jay will move forward.

112
00:07:55,810 --> 00:07:57,970
OK, so this is very simple problem.

113
00:07:58,330 --> 00:08:01,510
You have this, all this problem somewhere that you thought that is.

114
00:08:02,170 --> 00:08:04,360
So let's take a variable key for this area.

115
00:08:04,870 --> 00:08:06,640
So start from start.

116
00:08:06,820 --> 00:08:14,470
OK, so let's take a variable K so K will be starting from the starting index starting next.

117
00:08:14,540 --> 00:08:14,860
OK.

118
00:08:18,460 --> 00:08:25,750
So basically, this index I use for attriting or X, the index is for our over the next case, for our

119
00:08:25,750 --> 00:08:26,400
trading, our.

120
00:08:27,250 --> 00:08:29,060
And what condition we need to use.

121
00:08:29,320 --> 00:08:30,520
So while I.

122
00:08:30,640 --> 00:08:34,870
Is less than the custommade, Vijay is less than I was to end.

123
00:08:34,960 --> 00:08:36,340
I will do the comparison.

124
00:08:36,340 --> 00:08:37,580
I will do the comparison.

125
00:08:38,320 --> 00:08:39,789
So the correlation is very simple.

126
00:08:41,890 --> 00:08:53,320
So while I is less than our customer and Jay should be less than what it cost to end, so we need to

127
00:08:53,320 --> 00:08:54,170
do the comparison.

128
00:08:54,640 --> 00:09:06,880
So if the value eye is smaller, so if X or Y is it smaller than Vitalogy, then in that case it will

129
00:09:06,880 --> 00:09:15,540
be X or Y, so I will move forward and will move forward in the sales part, what they can do.

130
00:09:16,840 --> 00:09:21,220
So in the early part, the value of that index is smaller.

131
00:09:21,340 --> 00:09:29,250
So Aoki will be Buyology, so J will move forward and will move forward.

132
00:09:30,700 --> 00:09:31,160
Simple.

133
00:09:32,230 --> 00:09:33,090
So what I'm doing.

134
00:09:34,120 --> 00:09:36,160
So compare one and two.

135
00:09:36,290 --> 00:09:37,180
So one is smaller.

136
00:09:37,180 --> 00:09:40,630
I will put one here and now I is present at this index.

137
00:09:41,020 --> 00:09:42,940
So compare three with five.

138
00:09:42,940 --> 00:09:46,720
So compared it to so two will be here and G will move forward.

139
00:09:46,750 --> 00:09:48,110
So J is that the next five.

140
00:09:48,550 --> 00:09:50,350
So just pointing to value five.

141
00:09:50,590 --> 00:09:51,880
So compare three and five.

142
00:09:52,090 --> 00:09:54,160
They will be here and guess moving forward.

143
00:09:54,170 --> 00:09:55,370
OK is moving forward.

144
00:09:55,810 --> 00:09:58,080
So three will be present then I will reach seven.

145
00:09:58,420 --> 00:10:00,160
So you will compare seven with five.

146
00:10:00,700 --> 00:10:04,930
So you will put five J will be present at that element six.

147
00:10:05,260 --> 00:10:08,150
So you will compare seven and six, seven, six will be here.

148
00:10:08,440 --> 00:10:09,790
So J will reach the end.

149
00:10:10,180 --> 00:10:11,140
So J will reach.

150
00:10:11,440 --> 00:10:12,370
So G will become.

151
00:10:12,370 --> 00:10:14,020
And plus one when you will reach.

152
00:10:14,020 --> 00:10:16,030
And plus one you will come out of this via loop.

153
00:10:16,390 --> 00:10:18,760
And these are the elements.

154
00:10:18,760 --> 00:10:20,200
One, two, three, four, five and six.

155
00:10:20,410 --> 00:10:23,600
So basically one element is remaining, OK, so what to do.

156
00:10:24,310 --> 00:10:25,930
So basically there are two ways.

157
00:10:27,670 --> 00:10:33,430
So there are two ways that I can come out of this loop, the value of I will become the person or the

158
00:10:33,430 --> 00:10:34,690
value will become.

159
00:10:34,740 --> 00:10:37,420
And so we need to copy the rest of the elements.

160
00:10:37,990 --> 00:10:39,670
So let's copy the rest of the elements.

161
00:10:40,840 --> 00:10:41,560
So while.

162
00:10:42,970 --> 00:10:44,290
I is less than ideal.

163
00:10:45,490 --> 00:10:48,330
We need to copy the elements so AFIK.

164
00:10:49,300 --> 00:10:59,140
Will be ex of a Gabler's plus and plus plus similarly, we need to copy the rest of the elements.

165
00:11:00,440 --> 00:11:03,830
So while Jay is listing articles two and.

166
00:11:05,990 --> 00:11:15,890
So AFIK will be Ryoji and he will do Gabler's plus you will lose C++, so this is the code for the majority

167
00:11:15,890 --> 00:11:16,380
function.

168
00:11:16,490 --> 00:11:18,820
So our majority function will work properly.

169
00:11:20,810 --> 00:11:24,660
So that is how you can write the code for my chart base case.

170
00:11:24,680 --> 00:11:25,360
Very simple.

171
00:11:25,370 --> 00:11:26,630
Zero element or one element.

172
00:11:26,660 --> 00:11:28,820
Find out the word copied the elements.

173
00:11:28,820 --> 00:11:34,540
Greatorex and we saw the two areas and then master to order that is.

174
00:11:34,550 --> 00:11:38,870
So let's call this function Mussert and let's see whether our code is right or wrong.

175
00:11:39,320 --> 00:11:40,420
So let's copy the function.

176
00:11:43,520 --> 00:11:49,770
So my thought I have to give and I had to give the starting next, and I intend to give the last index,

177
00:11:50,150 --> 00:11:51,480
so let's create an area first.

178
00:11:52,940 --> 00:11:54,080
So if this is my area.

179
00:11:57,160 --> 00:12:03,100
And let's say these elements are seven cometary coma, one coma, five coma, six comatose.

180
00:12:03,880 --> 00:12:05,330
So these are six elements.

181
00:12:05,890 --> 00:12:07,930
So the last next will be five.

182
00:12:09,560 --> 00:12:18,440
And now let us print the ad so that we can see so I equals zero, I elastin six I placeless.

183
00:12:21,140 --> 00:12:21,770
Setout.

184
00:12:23,280 --> 00:12:23,910
Afie.

185
00:12:28,160 --> 00:12:29,490
So let's test our function.

186
00:12:32,450 --> 00:12:35,270
OK, so basically there is something wrong.

187
00:12:35,720 --> 00:12:37,180
The function is not working.

188
00:12:37,370 --> 00:12:38,880
So let's see what is the mistake.

189
00:12:39,170 --> 00:12:40,760
So let's start from here.

190
00:12:40,760 --> 00:12:42,000
Start with an end.

191
00:12:44,060 --> 00:12:45,140
So this is wrong.

192
00:12:45,440 --> 00:12:47,540
This will be a less than ideal standard.

193
00:12:50,210 --> 00:12:51,140
Let's test again.

194
00:12:52,780 --> 00:12:54,850
And now the elements are getting sorted.

195
00:12:54,880 --> 00:13:01,270
OK, so you can compare the elements for three one, five, six, two, and this is one, two, three,

196
00:13:01,270 --> 00:13:02,290
four, five and six.

197
00:13:02,740 --> 00:13:04,800
So basically our function is working.

198
00:13:07,120 --> 00:13:08,590
So let's give some more elements.

199
00:13:08,590 --> 00:13:13,060
Let's say this is element seven and this is element that certain.

200
00:13:14,290 --> 00:13:16,600
And let's add one or two more elements.

201
00:13:16,600 --> 00:13:17,470
Let's say three.

202
00:13:18,640 --> 00:13:19,490
So three is already.

203
00:13:19,630 --> 00:13:24,640
Let's make it minus five and let's add 78.

204
00:13:27,180 --> 00:13:32,190
So now the number of elements is one, two, three, four, five, six, seven and eight.

205
00:13:32,460 --> 00:13:38,000
So last election next will be seven and here it will be aired.

206
00:13:38,400 --> 00:13:40,200
So let's call the function mushahid.

207
00:13:43,560 --> 00:13:49,440
So basically, you can see that is getting started minus five, two, three, five, six, seven, 10

208
00:13:49,440 --> 00:13:49,920
and seven.

209
00:13:50,730 --> 00:13:52,430
So basically our function is working.

210
00:13:52,770 --> 00:13:56,640
So let's consider one case in which the number of elements are basically.

211
00:13:57,270 --> 00:14:00,770
So these are the even number of elements let's test for.

212
00:14:01,200 --> 00:14:02,490
So let's remove an element.

213
00:14:03,270 --> 00:14:06,420
So the last word next will be six and the number of elements is seven.

214
00:14:10,690 --> 00:14:16,190
So you can see our function is still working, our area is getting started and how it is getting sorted.

215
00:14:16,540 --> 00:14:18,940
So let me diren you one example, what you will do.

216
00:14:19,210 --> 00:14:23,530
So if this is you ready seven three one five six two.

217
00:14:24,010 --> 00:14:25,030
What you will do, you will do.

218
00:14:25,030 --> 00:14:26,230
I do that into two 1/2.

219
00:14:28,180 --> 00:14:32,620
So this will be 70 and when I'm dividing the areas into two 1/2.

220
00:14:36,110 --> 00:14:42,590
This will be basically five, six, two, you are playing Mozart on board half, so this idea will become

221
00:14:43,280 --> 00:14:46,400
one three seven decide, it will become two six five.

222
00:14:46,910 --> 00:14:50,760
And you are merging the two sort of you are merging to sort it out.

223
00:14:50,810 --> 00:14:53,800
So one, two, three, five, six and seven.

224
00:14:54,080 --> 00:14:55,460
So that is how it is working.

225
00:14:55,910 --> 00:15:01,030
So another way is basically it's seven three, one, five, six and two.

226
00:15:01,040 --> 00:15:02,090
This is our already.

227
00:15:03,490 --> 00:15:10,030
I told you that working it will be split it into two 1/2, seven driven and five six to.

228
00:15:12,300 --> 00:15:17,010
So the number of animals is also basically one side they will be to eliminate and either side there

229
00:15:17,010 --> 00:15:17,750
will be one element.

230
00:15:18,000 --> 00:15:18,960
So let's see the side.

231
00:15:19,170 --> 00:15:22,700
I have only one element and the right side I have two elements, three and one.

232
00:15:23,250 --> 00:15:24,960
Similarly, this will be five.

233
00:15:25,290 --> 00:15:28,910
And let's say the other side, I have to eliminate six and two.

234
00:15:29,790 --> 00:15:33,000
So similarly, this will be six and this will be two.

235
00:15:33,810 --> 00:15:34,790
So this will be three.

236
00:15:35,760 --> 00:15:36,600
This will be one.

237
00:15:37,140 --> 00:15:38,820
And now we will hear the case.

238
00:15:39,210 --> 00:15:43,910
So element one, so start is here and this here, Leontes one.

239
00:15:43,930 --> 00:15:48,720
So this is also sorted, sorted, sorted, sorted, merge these two.

240
00:15:48,720 --> 00:15:49,830
So it will be one entry.

241
00:15:51,030 --> 00:15:56,010
So this is a sort of that this is a sorted area must not lose order, that is so after merging the two

242
00:15:56,010 --> 00:16:01,220
sort of that is it will be one through seven so much these two areas.

243
00:16:01,230 --> 00:16:03,020
So these two areas are basically sorted.

244
00:16:03,030 --> 00:16:04,050
So it will be two six.

245
00:16:04,950 --> 00:16:06,050
This is also sorted out.

246
00:16:06,210 --> 00:16:08,790
So after merging, it will be two, five, six.

247
00:16:09,330 --> 00:16:11,190
So now this area is basically sorted.

248
00:16:11,190 --> 00:16:16,290
This area is basically sorted mostly to certain areas and they will get a certain area, which is one,

249
00:16:16,290 --> 00:16:18,270
two, three, five, six and seven.

250
00:16:18,630 --> 00:16:20,610
So that is how this function is working.

251
00:16:20,620 --> 00:16:22,230
This is my third function is working.

252
00:16:22,770 --> 00:16:24,270
So this is from this video.

253
00:16:25,250 --> 00:16:26,570
I will see you in the next one.

254
00:16:27,170 --> 00:16:27,680
Thank you.

