1
00:00:01,500 --> 00:00:03,090
Hey, guys, what's up?

2
00:00:03,780 --> 00:00:10,020
So in the last we do over togged about Selection's art, in this video, we will learn what is the Mozart

3
00:00:10,220 --> 00:00:10,630
algorithm?

4
00:00:11,280 --> 00:00:11,490
OK.

5
00:00:11,880 --> 00:00:13,110
So let's take an example.

6
00:00:13,470 --> 00:00:15,030
So suppose my art is.

7
00:00:20,730 --> 00:00:26,160
So might add elements are, let's say, five, four, three.

8
00:00:27,240 --> 00:00:29,040
One and two.

9
00:00:29,610 --> 00:00:30,570
So this is my area.

10
00:00:30,930 --> 00:00:34,360
So where those come compare just.

11
00:00:35,780 --> 00:00:37,150
So compare our descent.

12
00:00:37,880 --> 00:00:43,580
So four will be compared with five now in the final Lizzard for sure to come before five.

13
00:00:43,760 --> 00:00:44,030
OK.

14
00:00:44,450 --> 00:00:46,920
And so did Eddie for sure to come before five.

15
00:00:47,450 --> 00:00:48,690
Let's call it G.

16
00:00:50,290 --> 00:00:52,180
And this will be Jabe, less one.

17
00:00:53,750 --> 00:00:53,970
OK.

18
00:00:54,810 --> 00:00:57,680
So this for sure to come before 5:00.

19
00:00:57,750 --> 00:00:59,580
So what I will do, I will slap.

20
00:01:00,120 --> 00:01:01,550
So this will become food.

21
00:01:01,740 --> 00:01:03,330
And this will become five.

22
00:01:05,310 --> 00:01:09,150
My because in the finality for sure to come before five.

23
00:01:10,350 --> 00:01:11,430
Now, compare these to.

24
00:01:13,250 --> 00:01:14,650
Three sure to come before five.

25
00:01:15,420 --> 00:01:16,530
So slap again.

26
00:01:16,560 --> 00:01:18,540
So three and five.

27
00:01:19,350 --> 00:01:22,410
Now, again, compare what is sure to come before five.

28
00:01:23,310 --> 00:01:24,120
So when.

29
00:01:25,210 --> 00:01:25,630
Five.

30
00:01:26,050 --> 00:01:29,380
Now compare again to show to come before five.

31
00:01:29,920 --> 00:01:31,230
So again, look swiping.

32
00:01:31,720 --> 00:01:33,580
So two and five.

33
00:01:34,210 --> 00:01:36,880
So this is my new Eddie.

34
00:01:41,020 --> 00:01:41,860
So for.

35
00:01:43,410 --> 00:01:43,920
Three.

36
00:01:45,820 --> 00:01:46,330
One.

37
00:01:47,930 --> 00:01:48,290
To.

38
00:01:49,410 --> 00:01:51,970
And five, so this is my new day.

39
00:01:52,910 --> 00:01:56,520
Now I will do the same look compare for entry.

40
00:01:58,030 --> 00:02:02,830
Today is sure to come before 4:00, so step three and four.

41
00:02:03,690 --> 00:02:04,370
Now compare.

42
00:02:05,560 --> 00:02:06,960
Venture to come before Ford.

43
00:02:07,480 --> 00:02:14,070
So one and Ford now come bail for and to do a show to come before the Ford.

44
00:02:14,740 --> 00:02:17,950
So step two and Ford.

45
00:02:18,910 --> 00:02:21,550
Now compare Ford and five.

46
00:02:21,610 --> 00:02:23,110
So Ford should come before five.

47
00:02:23,160 --> 00:02:23,800
Do nothing.

48
00:02:24,750 --> 00:02:24,980
OK.

49
00:02:25,790 --> 00:02:26,690
So do nothing.

50
00:02:26,780 --> 00:02:27,030
OK.

51
00:02:28,330 --> 00:02:32,530
Now, our new ad is so our new ad is.

52
00:02:42,100 --> 00:02:42,610
Three.

53
00:02:43,760 --> 00:02:44,210
When?

54
00:02:45,340 --> 00:02:45,730
To.

55
00:02:46,890 --> 00:02:47,340
For.

56
00:02:48,460 --> 00:02:49,090
And faith.

57
00:02:50,660 --> 00:02:50,890
OK.

58
00:02:51,260 --> 00:02:51,950
So compare.

59
00:02:53,430 --> 00:02:54,880
Venture to come before a tree.

60
00:02:55,320 --> 00:02:55,980
So slap.

61
00:02:57,940 --> 00:02:58,660
Now compare.

62
00:02:59,900 --> 00:03:02,360
Those sure to come before 3:00, so slap.

63
00:03:04,540 --> 00:03:05,280
Now compare.

64
00:03:06,250 --> 00:03:07,120
So this is correct.

65
00:03:07,270 --> 00:03:07,440
OK.

66
00:03:07,630 --> 00:03:08,970
Three should appear before four.

67
00:03:09,340 --> 00:03:13,930
So do nothing now compare for to come before five.

68
00:03:14,710 --> 00:03:15,520
So do nothing.

69
00:03:16,930 --> 00:03:18,430
Now, our final today's.

70
00:03:20,150 --> 00:03:22,670
So this is our new Eddie.

71
00:03:26,630 --> 00:03:27,140
Van.

72
00:03:28,150 --> 00:03:29,920
Two, three.

73
00:03:30,930 --> 00:03:33,240
Four and five.

74
00:03:34,760 --> 00:03:35,700
So does this or today.

75
00:03:35,750 --> 00:03:37,100
And this is my final answer.

76
00:03:38,210 --> 00:03:40,220
So what if you will follow the same approach?

77
00:03:40,860 --> 00:03:41,270
Sepp.

78
00:03:42,880 --> 00:03:47,220
So if you compare, compare what will happen there, a decade equation.

79
00:03:47,290 --> 00:03:47,860
Do nothing.

80
00:03:49,230 --> 00:03:49,750
Compare.

81
00:03:50,150 --> 00:03:51,200
They are dead, correct?

82
00:03:51,270 --> 00:03:53,250
We shouldn't do nothing, compare.

83
00:03:53,420 --> 00:03:54,080
Do nothing.

84
00:03:54,680 --> 00:03:55,340
Compare.

85
00:03:55,700 --> 00:03:56,300
Do nothing.

86
00:03:56,990 --> 00:03:58,550
So this is my son, Daddy.

87
00:03:59,480 --> 00:04:03,290
So my question to you is, how many times do we have to.

88
00:04:04,070 --> 00:04:06,770
So how many times we have to do all this?

89
00:04:07,550 --> 00:04:10,610
So in this case, I was having five elements.

90
00:04:11,480 --> 00:04:14,640
So if I am having five elements, how many times I have died?

91
00:04:15,200 --> 00:04:16,040
So first time.

92
00:04:16,490 --> 00:04:17,300
Second time.

93
00:04:21,090 --> 00:04:23,850
And third time, so I did three times.

94
00:04:23,880 --> 00:04:26,460
So after doing two times, I got my answer.

95
00:04:27,170 --> 00:04:27,410
OK.

96
00:04:27,930 --> 00:04:34,460
So if the number of elements was five after doing three times, I got my final answer.

97
00:04:36,240 --> 00:04:36,660
Now.

98
00:04:38,950 --> 00:04:41,200
Now, let us consider the worst case.

99
00:04:42,240 --> 00:04:43,860
So what will happen in worst case?

100
00:04:45,360 --> 00:04:46,980
So it will happen in worst case.

101
00:04:47,070 --> 00:04:55,380
My area will be reverse this order, so reverse order means my area will be sorted in reverse order.

102
00:04:55,440 --> 00:04:59,730
So four, three, two and one.

103
00:05:00,060 --> 00:05:02,190
So my adays started in reverse order.

104
00:05:02,430 --> 00:05:04,110
So this will be the worst case.

105
00:05:04,200 --> 00:05:04,480
OK.

106
00:05:05,070 --> 00:05:06,570
So this is worst case.

107
00:05:07,840 --> 00:05:10,560
Now, hey, Ed, we will try to understand that for any elements.

108
00:05:10,630 --> 00:05:21,210
How many times we have to do stepping so compared and to step three and four compare and swap so to

109
00:05:21,980 --> 00:05:24,030
for compare and.

110
00:05:24,400 --> 00:05:29,050
So when and for so first time soffer doing first time.

111
00:05:29,050 --> 00:05:30,010
My new ad is.

112
00:05:32,610 --> 00:05:33,090
Three.

113
00:05:34,210 --> 00:05:34,560
To.

114
00:05:35,670 --> 00:05:37,340
When and for.

115
00:05:37,440 --> 00:05:49,920
So this is my new ETTY combat and swap -- bed and swab -- bed and do nothing.

116
00:05:50,490 --> 00:05:51,290
So a second time.

117
00:05:53,210 --> 00:05:54,320
Now, I might add, is.

118
00:05:55,860 --> 00:05:56,310
So.

119
00:05:58,180 --> 00:05:59,620
My adays to.

120
00:06:00,770 --> 00:06:03,300
Then one, then three.

121
00:06:04,370 --> 00:06:05,150
And then for.

122
00:06:07,320 --> 00:06:09,270
So compared and slap.

123
00:06:10,050 --> 00:06:13,320
So when we come here, they will come here, come back here.

124
00:06:13,590 --> 00:06:14,190
Do nothing.

125
00:06:14,820 --> 00:06:15,390
Compare.

126
00:06:15,480 --> 00:06:16,050
Do nothing.

127
00:06:16,530 --> 00:06:17,280
So third time.

128
00:06:17,880 --> 00:06:19,170
So after doing two times.

129
00:06:22,490 --> 00:06:25,910
So after doing two times, I got my final answer.

130
00:06:25,970 --> 00:06:29,570
My edit got sorted one, two, three and four.

131
00:06:30,510 --> 00:06:32,540
OK, so my add is sorted.

132
00:06:33,140 --> 00:06:35,450
So this was the worst case.

133
00:06:36,410 --> 00:06:40,670
And I have to do three times the number of elements are forward.

134
00:06:41,420 --> 00:06:43,370
So I have to do three times.

135
00:06:45,440 --> 00:06:45,610
OK.

136
00:06:45,800 --> 00:06:52,040
So this wrapping things I have to do three times so we can also say like this that.

137
00:06:55,080 --> 00:06:56,520
For starting in numbers.

138
00:06:58,080 --> 00:07:06,330
For sorting in numbers, what to do is start and minus when numbers start and minus one numbers.

139
00:07:06,690 --> 00:07:08,190
You want to sort end numbers.

140
00:07:08,640 --> 00:07:09,540
I'm seeing you.

141
00:07:09,570 --> 00:07:10,140
Hey buddy.

142
00:07:10,230 --> 00:07:11,640
Start and minus one numbers.

143
00:07:12,000 --> 00:07:14,070
So if and minus the numbers are sorted.

144
00:07:14,130 --> 00:07:21,060
That means if they are at the correct position, then the last number will also be at its great position.

145
00:07:21,210 --> 00:07:21,500
OK.

146
00:07:22,050 --> 00:07:24,750
So that is the reason for any close forward.

147
00:07:24,900 --> 00:07:26,670
I have to do this slipping two times.

148
00:07:27,330 --> 00:07:27,620
Why?

149
00:07:27,930 --> 00:07:29,670
Because for sorting in numbers.

150
00:07:29,790 --> 00:07:36,330
If we start and minus one numbers, then the last number will automatically get its correct position.

151
00:07:39,070 --> 00:07:40,300
So court is very simple.

152
00:07:41,080 --> 00:07:43,810
First of all, how many times do we have to do this wrapping things?

153
00:07:44,320 --> 00:07:45,340
And minus one times.

154
00:07:45,370 --> 00:07:50,080
So count to close one count less than or equal to N minus or times.

155
00:07:50,160 --> 00:07:51,740
We have to do this slapping thing.

156
00:07:52,330 --> 00:07:53,230
And the count plus.

157
00:07:53,230 --> 00:07:53,560
Plus.

158
00:07:54,950 --> 00:07:55,210
OK.

159
00:07:56,180 --> 00:07:58,390
Now I will start from zero.

160
00:07:58,570 --> 00:07:59,710
I have to start from zero.

161
00:07:59,800 --> 00:08:01,300
The slapping you can see here.

162
00:08:03,210 --> 00:08:05,860
The setting was starting from zero, and this is.

163
00:08:06,160 --> 00:08:06,760
Minus one.

164
00:08:08,230 --> 00:08:14,590
OK, so the spangly start from zero, so this is G and this will be the final rally of G.

165
00:08:16,150 --> 00:08:22,930
So jaivin go from this to this gibber hotel and minus to Vion minus two, because I'm comparing G and

166
00:08:22,930 --> 00:08:26,420
G plus one, if you will take J here.

167
00:08:26,860 --> 00:08:29,450
Then J plus one will become N.

168
00:08:30,010 --> 00:08:35,380
And if you will write a fan, that will give you segmentation fault.

169
00:08:38,730 --> 00:08:40,290
So Jay will start from zero.

170
00:08:41,130 --> 00:08:45,720
Jay will go to second last position and Jay Pless place.

171
00:08:46,200 --> 00:08:48,360
So what I was doing if.

172
00:08:50,060 --> 00:08:54,220
F g is greater than a f j plus one.

173
00:08:55,370 --> 00:09:00,500
I am comparing to our descent values, then what I will do I will scrap.

174
00:09:01,990 --> 00:09:04,550
Swab of J and a of jobless when.

175
00:09:07,660 --> 00:09:09,130
So this is all that we have to do.

176
00:09:09,940 --> 00:09:10,230
OK?

177
00:09:11,460 --> 00:09:12,840
So Vion minus two.

178
00:09:13,320 --> 00:09:16,440
So if the value of JS and minus to put J and minus two.

179
00:09:16,830 --> 00:09:19,200
So this really will become N minus one.

180
00:09:19,470 --> 00:09:19,860
Correct.

181
00:09:20,310 --> 00:09:21,060
Now put.

182
00:09:21,180 --> 00:09:22,770
And J equals and minus one.

183
00:09:23,640 --> 00:09:25,260
So if you put the Jan minus one.

184
00:09:25,350 --> 00:09:28,980
This will literally become an because and minus one.

185
00:09:29,520 --> 00:09:29,970
Plus one.

186
00:09:30,000 --> 00:09:31,390
So this value will become N.

187
00:09:31,760 --> 00:09:33,660
And you are doing a off in.

188
00:09:35,150 --> 00:09:36,640
Virtual guru segmentation fault.

189
00:09:36,760 --> 00:09:38,920
So that is the reason I will go to jail.

190
00:09:39,010 --> 00:09:39,760
And minus two.

191
00:09:42,050 --> 00:09:42,350
OK.

192
00:09:44,380 --> 00:09:45,760
So this is all that we have to do.

193
00:09:46,210 --> 00:09:47,080
So if Jay.

194
00:09:47,830 --> 00:09:48,980
So this is my Jay.

195
00:09:49,420 --> 00:09:50,720
And this is Jay Placemen.

196
00:09:51,330 --> 00:09:52,510
So I believe what should happen.

197
00:09:52,540 --> 00:09:58,810
The value at the J should be less than Value-Add Jeab less than to get the element sorted in ascending

198
00:09:58,810 --> 00:09:59,110
order.

199
00:09:59,560 --> 00:10:06,640
So if Jay is bigger, if Jay is bigger than SREP, then we have to swap.

200
00:10:08,260 --> 00:10:09,960
OK, so let us ride the cold.

201
00:10:11,340 --> 00:10:12,990
So one more thing before writing code.

202
00:10:13,500 --> 00:10:14,910
Have you noticed one thing here?

203
00:10:16,670 --> 00:10:23,120
So if you look carefully, the biggest way you enforced arbitration reaches its correct position.

204
00:10:23,540 --> 00:10:25,460
So five is the biggest failure in the area.

205
00:10:25,790 --> 00:10:32,660
And in one eye attrition, five reach its correct position in second attrition, the second largest

206
00:10:32,660 --> 00:10:35,720
value, you reached its correct position.

207
00:10:36,440 --> 00:10:42,240
Similarly, in the third arbitration, the third largest value guarded correct position.

208
00:10:42,740 --> 00:10:44,130
And similarly, there are two.

209
00:10:44,210 --> 00:10:47,210
And then when you can see here also.

210
00:10:48,700 --> 00:10:56,170
So in the first iteration, the largest way Lou got it correct position in the second operation, the

211
00:10:56,170 --> 00:11:02,780
second largest way, Lou, got the second largest way, Lou Waters correct position in the turnout operation,

212
00:11:03,100 --> 00:11:04,200
the third largest trade Lou.

213
00:11:04,270 --> 00:11:04,720
Got it.

214
00:11:04,750 --> 00:11:05,650
Correct position.

215
00:11:05,860 --> 00:11:06,100
OK.

216
00:11:06,550 --> 00:11:07,420
So you can see.

217
00:11:09,430 --> 00:11:15,110
In the first hour operation, so forced attrition, largest Relu welcome, largest relief will reach.

218
00:11:15,190 --> 00:11:23,150
And in the second iteration, the second largest, Trelew, will reach at its correct position partite

219
00:11:23,240 --> 00:11:23,740
duration.

220
00:11:24,340 --> 00:11:27,550
The third largest, Trelew, will reach at its current position.

221
00:11:28,000 --> 00:11:31,360
Okay, so my area is getting slaughtered in this way.

222
00:11:33,840 --> 00:11:35,670
So this is my unsorted.

223
00:11:37,880 --> 00:11:45,440
And this part is sordid, so the sorted is in this week in case of Selection's art.

224
00:11:46,520 --> 00:11:47,510
So if you remember.

225
00:11:48,920 --> 00:11:56,800
In the selection sort, what we did was, if you are standing here, find the smallest value in the

226
00:11:56,800 --> 00:11:59,270
right hand side and put that value here.

227
00:11:59,800 --> 00:12:06,550
So in forced isolation, the smallest value will reach added position in the second rotation.

228
00:12:06,580 --> 00:12:11,720
The second, the smallest value will reach at its correct position interpretation.

229
00:12:12,160 --> 00:12:16,030
The third smallest value will reach at its great position.

230
00:12:16,630 --> 00:12:19,030
So in selections art, what is happening?

231
00:12:19,450 --> 00:12:22,330
My edit is getting sorted in this way.

232
00:12:23,140 --> 00:12:27,390
So it is getting started in this way and this part is unsorted.

233
00:12:29,260 --> 00:12:34,900
And in case of bubble, my ED is getting sorted in this way and this part is unsorted.

234
00:12:37,690 --> 00:12:46,630
So this is sort of my Eddie is my it is getting sorted in this way first and largest, you know, second

235
00:12:46,630 --> 00:12:48,130
largest, then third largest.

236
00:12:48,310 --> 00:12:50,710
And here first, the smallest value.

237
00:12:50,800 --> 00:12:52,030
Then the second smallest value.

238
00:12:52,060 --> 00:12:54,910
Then Tourism Australia, then forced military ends on.

239
00:12:57,310 --> 00:12:59,190
I so let us write the code for Bubble Sword.

240
00:12:59,450 --> 00:13:00,920
So the court is very simple.

241
00:13:02,290 --> 00:13:03,760
How many times we have to perform this?

242
00:13:05,140 --> 00:13:06,520
And minus one times.

243
00:13:07,030 --> 00:13:07,270
OK.

244
00:13:07,360 --> 00:13:07,630
Why?

245
00:13:07,690 --> 00:13:11,260
Because we have already seen the worst case in worst case.

246
00:13:11,350 --> 00:13:14,080
If the radio fan goes forward with it two times.

247
00:13:14,500 --> 00:13:15,160
So we have to do.

248
00:13:15,160 --> 00:13:16,240
And minus one times.

249
00:13:17,480 --> 00:13:19,010
And generally start from zero.

250
00:13:19,040 --> 00:13:20,450
I will start campaigning from zero.

251
00:13:20,480 --> 00:13:25,070
I will come back J and J plus one since I am using the year plus one.

252
00:13:25,430 --> 00:13:27,500
So the maximum end of the year will be N minus two.

253
00:13:27,890 --> 00:13:28,110
OK.

254
00:13:28,640 --> 00:13:29,210
That makes sense.

255
00:13:29,210 --> 00:13:33,350
I love JVB and minus two because I am comparing David J plus one.

256
00:13:35,430 --> 00:13:39,040
Okay, so if O.J. question my niece, do this where Luis and minus one.

257
00:13:40,110 --> 00:13:43,590
So if Jay is good, then Jay Letwin, then I will lose Heping.

258
00:13:45,190 --> 00:13:46,210
So they decide the gold.

259
00:13:47,740 --> 00:13:49,990
So there does name this Veloz bubble sort.

260
00:13:55,300 --> 00:13:56,890
So what was art and art CPB?

261
00:14:11,780 --> 00:14:13,520
So let us take input from the user.

262
00:14:17,230 --> 00:14:20,860
So four and I equals zero.

263
00:14:21,040 --> 00:14:28,970
I let them and I bless, bless, sit in if I let us make an error.

264
00:14:30,280 --> 00:14:32,470
So the size of the arrays and.

265
00:14:35,120 --> 00:14:37,310
Now I will write a function bubbles out.

266
00:14:37,940 --> 00:14:41,990
So bubble what Mozart will take as input.

267
00:14:42,680 --> 00:14:47,330
So Bubbles Art will take two things, Eddy and the size of the eddy.

268
00:14:48,260 --> 00:14:49,580
And it will start my eddy.

269
00:14:49,970 --> 00:14:51,010
So my art is ordered.

270
00:14:51,110 --> 00:15:02,810
Now let us print thus Outhred any sort of order intake was a zero a less than in a Lesbos sea out of

271
00:15:02,870 --> 00:15:03,080
a.

272
00:15:05,460 --> 00:15:07,250
OK, so let's inside the quarter for the wizard.

273
00:15:08,760 --> 00:15:10,660
So this function will return void.

274
00:15:11,080 --> 00:15:11,210
OK.

275
00:15:11,490 --> 00:15:13,260
Because I'm just sorting that out.

276
00:15:13,290 --> 00:15:17,850
I am not returning any value to mean so bubble.

277
00:15:19,140 --> 00:15:24,040
Saad, it is taking two things as input first lady.

278
00:15:24,660 --> 00:15:27,480
And second, the size of the Eddie.

279
00:15:32,080 --> 00:15:43,060
So forward how many times and minus one times Clow count equals one count less than or equals and minus

280
00:15:43,060 --> 00:15:46,510
one count plus plus.

281
00:15:50,250 --> 00:15:54,810
Now, what we have to do, we have to just compare and discern numbers.

282
00:15:55,350 --> 00:16:01,710
So I'm starting from zero G is less than articles two and minus two.

283
00:16:01,800 --> 00:16:02,860
So this is important.

284
00:16:02,970 --> 00:16:05,330
And minus two J.

285
00:16:05,340 --> 00:16:05,640
Plus.

286
00:16:05,640 --> 00:16:06,000
Plus.

287
00:16:09,030 --> 00:16:11,970
Now, what do you do, you will compare their descent to numbers.

288
00:16:12,510 --> 00:16:20,870
So if A of G is greater than he of J plus one, then you have to swab.

289
00:16:21,900 --> 00:16:29,790
So swab of G and A of G plus one.

290
00:16:31,320 --> 00:16:33,100
So this is all that we have to do.

291
00:16:33,650 --> 00:16:33,910
OK.

292
00:16:34,650 --> 00:16:38,010
So I told you ARIAD passed by at events.

293
00:16:38,130 --> 00:16:44,170
So if I am changing the values of Eddie here, this changes will be reflected in function men.

294
00:16:44,780 --> 00:16:45,840
OK, so one more time.

295
00:16:46,230 --> 00:16:51,950
I told you when you pass Eddie to a function than Eddie, I passed by reference.

296
00:16:52,320 --> 00:16:59,460
So if you will do changes in the Eddie, those changes will be reflected in the main function in the

297
00:16:59,520 --> 00:17:00,690
calling function.

298
00:17:04,030 --> 00:17:12,790
So a number of elements out of five and the values are, let's say five, four, three, two and one.

299
00:17:13,870 --> 00:17:16,870
So this is my output, which is Saajid.

300
00:17:20,490 --> 00:17:27,930
Let's say member of elements are five and the elements are five, four, three, one and two.

301
00:17:29,250 --> 00:17:31,480
So again, this is producing the correct output.

302
00:17:33,450 --> 00:17:42,870
So let's say the number of elements are forward and the elements are at the door during be 10 and 50,

303
00:17:44,310 --> 00:17:46,320
so elements are getting started.

304
00:17:47,220 --> 00:17:49,830
So this is how bubbles art works.

305
00:17:51,840 --> 00:17:54,690
Okay, so now let us discuss one last thing.

306
00:17:57,530 --> 00:17:58,850
So how many steps?

307
00:17:59,300 --> 00:18:01,740
But Mozart takes two is ordinary.

308
00:18:02,660 --> 00:18:08,090
So this outer function is earning approximately and minus one times.

309
00:18:09,710 --> 00:18:13,700
So outer loop is earning and minus one times and inner loop is also running.

310
00:18:14,120 --> 00:18:15,530
And minus two times.

311
00:18:16,520 --> 00:18:24,260
So a number of steps, number of steps equals and minus one and two and minus two.

312
00:18:24,920 --> 00:18:25,120
OK.

313
00:18:25,280 --> 00:18:26,600
So these are the number of steps.

314
00:18:27,320 --> 00:18:34,460
So if you will multiply them, we will get and squared them, then anthem and then some constant.

315
00:18:34,970 --> 00:18:35,220
OK.

316
00:18:35,840 --> 00:18:38,410
So let's put an inquest into the power six.

317
00:18:39,020 --> 00:18:43,630
So this really will be ten to the power to this value will return to the power six.

318
00:18:43,700 --> 00:18:45,200
And this is something constant.

319
00:18:46,130 --> 00:18:51,890
Now tell me in front of this doesn't have any significance.

320
00:18:52,520 --> 00:18:52,910
No.

321
00:18:53,820 --> 00:18:58,700
And friend often of the power will well but the power of six is nothing.

322
00:18:59,210 --> 00:18:59,490
OK.

323
00:18:59,780 --> 00:19:04,410
So I can say the number of steps is a close to end squared.

324
00:19:06,000 --> 00:19:10,810
OK, so the number of steps is actually called time complexity.

325
00:19:13,270 --> 00:19:19,810
Time, complexity and complexity means how many number of steps your program took to execute.

326
00:19:21,100 --> 00:19:21,340
OK.

327
00:19:21,460 --> 00:19:23,020
So this thing is clear.

328
00:19:23,410 --> 00:19:24,600
So how we report them?

329
00:19:24,640 --> 00:19:25,330
Complexity.

330
00:19:25,780 --> 00:19:29,680
We will write big or record and square.

331
00:19:30,310 --> 00:19:33,140
So this is called time, complexity of bubble sort.

332
00:19:33,730 --> 00:19:35,910
So this is the time, complexity of bubbles.

333
00:19:37,030 --> 00:19:37,930
So what was the time?

334
00:19:37,960 --> 00:19:39,750
Complexity of selection's art.

335
00:19:40,180 --> 00:19:43,120
So time, complexity of Selection's art was also in the square.

336
00:19:44,440 --> 00:19:46,330
Okay, so selection's our time.

337
00:19:46,330 --> 00:19:48,280
Complexity was also in the square.

338
00:19:48,700 --> 00:19:52,180
And the time complexity of bubble sort is also and square.

339
00:19:54,020 --> 00:19:57,050
Now, any idea why we calculate time, complexity?

340
00:19:58,380 --> 00:19:58,830
So.

341
00:20:01,690 --> 00:20:03,280
Suppose you want to buy Ocado.

342
00:20:04,630 --> 00:20:05,560
So what do you will check?

343
00:20:06,030 --> 00:20:06,490
It will check.

344
00:20:07,030 --> 00:20:07,990
What is the mileage?

345
00:20:08,410 --> 00:20:09,430
What is the cost?

346
00:20:11,160 --> 00:20:12,510
How many number of seats?

347
00:20:14,460 --> 00:20:15,960
What is average speed?

348
00:20:16,830 --> 00:20:18,070
And there are many factor.

349
00:20:18,600 --> 00:20:18,910
OK.

350
00:20:19,290 --> 00:20:22,680
So for deciding which car to buy, you will see many factors.

351
00:20:23,570 --> 00:20:23,870
OK.

352
00:20:24,180 --> 00:20:25,950
So there are many starting.

353
00:20:25,950 --> 00:20:26,610
And what items?

354
00:20:26,850 --> 00:20:29,370
There are many sorting algorithms.

355
00:20:30,270 --> 00:20:33,720
How we will decide which sorting algorithm is best.

356
00:20:35,150 --> 00:20:35,850
So what we will do.

357
00:20:35,900 --> 00:20:43,580
We will find how much time is my program taking to execute the algorithm which take the least amount

358
00:20:43,580 --> 00:20:44,120
of time.

359
00:20:45,020 --> 00:20:49,310
The algorithm, which takes the least amount of time, is the best algorithm.

360
00:20:50,360 --> 00:20:50,610
OK.

361
00:20:50,870 --> 00:20:57,020
So that is the reason we calculate, Pam, complexity of the program to compare to algorithms or to

362
00:20:57,020 --> 00:20:58,400
compare two programs.

363
00:20:59,060 --> 00:21:01,490
So both levels, art and selections.

364
00:21:01,490 --> 00:21:05,490
Art both Pam complexity is N Square.

365
00:21:05,990 --> 00:21:09,030
They both take and square number of steps to execute.

366
00:21:10,940 --> 00:21:15,140
OK, so Julia, time complexity is a very big topic.

367
00:21:15,590 --> 00:21:19,100
I have just given you an introduction to complexity.

368
00:21:19,520 --> 00:21:21,590
That is why we calculate time complexity.

369
00:21:21,650 --> 00:21:21,920
OK.

370
00:21:22,280 --> 00:21:23,990
So this was just an introduction to time.

371
00:21:23,990 --> 00:21:26,570
Complexity and complexity is a big topic.

372
00:21:28,100 --> 00:21:28,360
OK.

373
00:21:29,060 --> 00:21:30,320
So this is it for this we do.

374
00:21:30,380 --> 00:21:32,840
If you have any doubt in bubbles, Art, you can ask me.

375
00:21:33,290 --> 00:21:33,830
Thank you.
