1
00:00:01,850 --> 00:00:02,490
Hi, everyone.

2
00:00:02,510 --> 00:00:06,200
So in this session, we are going to learn something which is called Vector's.

3
00:00:06,710 --> 00:00:11,210
So if you remember the U.S. Suenos, we cover the problem.

4
00:00:11,360 --> 00:00:14,900
We implemented a class and the name of the class was dynamic class.

5
00:00:15,290 --> 00:00:16,340
Now it is a vector.

6
00:00:16,550 --> 00:00:18,950
So vector is basically inbuilt dynamic.

7
00:00:18,950 --> 00:00:19,220
Very.

8
00:00:20,610 --> 00:00:26,100
So whenever we have a feeling that I want to use that imagery, what we will use, we will use Vector

9
00:00:26,100 --> 00:00:31,590
because it is and it is provided by C++ so it isn't built and we can directly use vectors.

10
00:00:32,960 --> 00:00:39,050
Now, what are the main two properties of vector, so just like the Democratic class, that is exactly

11
00:00:39,050 --> 00:00:43,760
the same as dynamic class or what will happen to the first property is basically you do not have to

12
00:00:43,760 --> 00:00:45,740
give the size of the vector add friend.

13
00:00:46,370 --> 00:00:47,370
You don't have to give.

14
00:00:47,720 --> 00:00:52,040
So if you are creating an area, how do we create a net without end?

15
00:00:52,280 --> 00:00:56,810
And then we will give the site, for example, the existing word for creating the vector.

16
00:00:56,820 --> 00:00:58,090
You do not have to give size.

17
00:00:58,910 --> 00:01:01,140
So that is the main benefit of the vector.

18
00:01:01,770 --> 00:01:07,220
There is no need to give size and the second benefit of using that already is, is basically you can

19
00:01:07,220 --> 00:01:09,440
insert as much number of elements as you want.

20
00:01:10,470 --> 00:01:16,020
If we consider the day you cannot push, you cannot insert more than 10 elements, you cannot insert

21
00:01:16,020 --> 00:01:17,810
11 elements inside this area.

22
00:01:18,270 --> 00:01:23,390
But if you are using vector since the vectors dynamic, so what will happen?

23
00:01:23,670 --> 00:01:25,740
We all know the property of vectors.

24
00:01:25,740 --> 00:01:28,070
Basically, it will double the size of this field.

25
00:01:29,440 --> 00:01:32,260
So, for example, if the workplace initially decides to.

26
00:01:33,290 --> 00:01:37,890
If you will push the two elements, basically, if the victories failed, then what will happen next?

27
00:01:39,260 --> 00:01:43,540
So now the current size of the vector is basically four and you can insert the elements here.

28
00:01:44,270 --> 00:01:48,260
Similarly, if this computer that is filled, then what will happen?

29
00:01:48,770 --> 00:01:50,510
That will again the size.

30
00:01:50,570 --> 00:01:52,040
So the size will become it.

31
00:01:52,730 --> 00:01:55,850
If this factor is full, then the size will become 16.

32
00:01:56,150 --> 00:01:58,160
So effectively keep doubling its size.

33
00:01:58,160 --> 00:02:01,400
And basically you can insert as much number of elements as you want.

34
00:02:03,020 --> 00:02:08,720
But with that, once you give the size, you cannot insert more than 10 elements in this case.

35
00:02:09,680 --> 00:02:12,830
But with Vector, you can insert as much number of elements as you want.

36
00:02:13,100 --> 00:02:16,400
And initially you don't have to give any size to create development vector.

37
00:02:17,240 --> 00:02:18,860
So these are the two main properties.

38
00:02:18,860 --> 00:02:19,890
Why use vector?

39
00:02:20,750 --> 00:02:22,450
So now let's see Vector in action.

40
00:02:22,580 --> 00:02:24,560
Let us see how we can use vector.

41
00:02:26,570 --> 00:02:30,410
So first, let's let's see how do we create a vector?

42
00:02:32,070 --> 00:02:34,410
So I have to right the key word, Victor.

43
00:02:35,480 --> 00:02:38,640
So I will write Victor Victory.

44
00:02:39,440 --> 00:02:40,940
So is this right or wrong?

45
00:02:40,940 --> 00:02:41,530
This is wrong.

46
00:02:41,540 --> 00:02:41,770
Why?

47
00:02:41,780 --> 00:02:44,140
Because Victor is implemented using template.

48
00:02:44,630 --> 00:02:46,820
So basically you have to give the dinner table.

49
00:02:46,820 --> 00:02:47,020
So.

50
00:02:47,520 --> 00:02:49,820
So I want to create vector of integers.

51
00:02:51,080 --> 00:02:54,230
So you have to write what you want, the story in your vector.

52
00:02:54,260 --> 00:02:57,050
I want the story, A.J., so you have to give in here.

53
00:02:58,160 --> 00:03:01,670
Now, as discussed many times, there are two ways to create victory.

54
00:03:01,700 --> 00:03:06,320
One is using this tactical location and the other one is basically dynamic location.

55
00:03:07,530 --> 00:03:10,440
So now see this index for creating vector dynamically.

56
00:03:11,490 --> 00:03:15,960
So Star V.P. Victor Point, this is New Keever, then Victor.

57
00:03:17,480 --> 00:03:22,850
Indigence and this Syntex, so this is actually.

58
00:03:23,880 --> 00:03:25,980
Dynamic and this one.

59
00:03:27,000 --> 00:03:33,150
It is actually static and we all know the difference between the static in the dynamic dynamic means

60
00:03:33,930 --> 00:03:35,410
we have to dilute it ourselves.

61
00:03:35,920 --> 00:03:37,820
It will not be deleted automatically.

62
00:03:37,830 --> 00:03:39,110
We have to delete the structure.

63
00:03:39,590 --> 00:03:43,560
But if we are allocating static memory, then what will happen?

64
00:03:43,950 --> 00:03:48,650
So this vector will get deleted automatically once it will reach out of scope.

65
00:03:49,020 --> 00:03:49,560
Simple.

66
00:03:50,070 --> 00:03:53,780
So now let's see how we can insert the elements inside the vector.

67
00:03:54,390 --> 00:04:00,450
So for inserting the elements inside the vector, we have a function push back so we don't push back

68
00:04:00,900 --> 00:04:02,520
and let's say I want to insert them.

69
00:04:03,390 --> 00:04:06,360
So as the name suggests, what is the use of push back?

70
00:04:06,750 --> 00:04:13,110
So suppose this is my vector now push back means, as the name suggests, I will push the element at

71
00:04:13,110 --> 00:04:13,620
the last.

72
00:04:13,830 --> 00:04:15,750
So 10 will be pushed at the last.

73
00:04:15,750 --> 00:04:18,600
But since at this point of time a vector is empty.

74
00:04:18,899 --> 00:04:22,110
So 10 will be pushed at different because the effect is empty.

75
00:04:22,470 --> 00:04:27,280
But if you will push more elements, for example, you will push twenty and then you, if you will push

76
00:04:27,280 --> 00:04:28,460
thirty, then what will happen.

77
00:04:29,160 --> 00:04:32,780
So first 20 will be pushed, then 30 will be pushed.

78
00:04:33,120 --> 00:04:36,660
So this will be the state of the vector 10, 20 and then 30.

79
00:04:37,570 --> 00:04:40,470
OK, so let's push back function in action.

80
00:04:40,830 --> 00:04:43,430
So let us push more elements.

81
00:04:43,440 --> 00:04:44,730
So let us copy this.

82
00:04:47,320 --> 00:04:52,660
And we don't have to worry about sales, if their vehicle gets filled, it size will become double.

83
00:04:52,870 --> 00:04:55,300
So push as much a number of elements as you want.

84
00:04:56,610 --> 00:05:01,440
So currently, the size of my vatos, basically three days containing three elements.

85
00:05:02,450 --> 00:05:07,610
Now, how to access those elements, so we have square brackets, so just like in any.

86
00:05:09,200 --> 00:05:12,530
We can access the elements of the vector using the square brackets.

87
00:05:14,100 --> 00:05:17,730
So let us copy this and let us access the elements.

88
00:05:22,530 --> 00:05:28,980
V0, we went and we do so I'm pushing these three elements and then I am printing these three elements

89
00:05:29,100 --> 00:05:29,630
simple.

90
00:05:30,270 --> 00:05:31,920
So let's run our program.

91
00:05:33,410 --> 00:05:36,950
So basically, we are getting at it at this line and what is the reality?

92
00:05:38,080 --> 00:05:41,380
The error is basically V was not declared in this scope.

93
00:05:43,150 --> 00:05:48,940
So if you want to use Vector, what we have to do, we have to include a file, has to include vector.

94
00:05:56,260 --> 00:06:00,660
So after including this file has concluded that it will not give us error.

95
00:06:00,710 --> 00:06:02,020
So let's turn our program.

96
00:06:04,530 --> 00:06:08,490
And this is my output, so that's how that is working.

97
00:06:11,290 --> 00:06:16,100
Now, can I change the elements once I have inserted those elements, obviously.

98
00:06:16,870 --> 00:06:21,350
So what I will use, I will use square backwards to change the elements.

99
00:06:21,370 --> 00:06:24,370
So suppose I want to change the element presented the next one.

100
00:06:24,400 --> 00:06:31,330
So what I will do while one is, let's say and so initially it was 20, now I change its value 200.

101
00:06:31,330 --> 00:06:31,990
So let's see.

102
00:06:35,240 --> 00:06:40,340
So then hundred, and then today, initially this hundred, it was 20.

103
00:06:42,290 --> 00:06:47,180
So this is great, because just like it used to work in that, it would also work for Victus.

104
00:06:48,610 --> 00:06:53,180
So since Victor also has square records, so what is the need of push back function?

105
00:06:53,980 --> 00:06:58,090
So what I want to say here is so initially I have three elements inside the vector.

106
00:06:58,120 --> 00:06:59,710
Now, let us push the fourth element.

107
00:07:00,220 --> 00:07:05,440
So can I push the elements using this great bracket just like we used to do in Eddies?

108
00:07:05,890 --> 00:07:06,760
Can we do this?

109
00:07:08,080 --> 00:07:11,950
So are these two lines valid, so let's try to understand.

110
00:07:13,390 --> 00:07:19,990
So if you will think logically, this should not work, because if these two lines worked, then what

111
00:07:19,990 --> 00:07:21,450
is the use of push back function?

112
00:07:21,970 --> 00:07:24,120
So that means these two lines will not work.

113
00:07:25,280 --> 00:07:30,740
So why do we need to push back function, what is the importance of push back function so push back

114
00:07:30,740 --> 00:07:32,450
function inside the push back function?

115
00:07:32,450 --> 00:07:33,050
What will do?

116
00:07:33,050 --> 00:07:34,550
So there are checks implemented.

117
00:07:34,910 --> 00:07:37,340
It will check on what is the current size of the vector.

118
00:07:37,970 --> 00:07:40,600
If the vector is getting filled, I have to double the size.

119
00:07:41,030 --> 00:07:46,550
So all these things are implemented in push back function that way for inserting the element we will

120
00:07:46,550 --> 00:07:48,200
always use push back function.

121
00:07:50,030 --> 00:07:57,170
So if you will use this, then what will happen so the size of the vector will not increase, so size

122
00:07:57,830 --> 00:08:02,090
increase, class size of the vector will not increase.

123
00:08:02,960 --> 00:08:04,560
So what are the elements?

124
00:08:04,580 --> 00:08:09,140
Do I have so I have 10, then I have 20 and then I have 30.

125
00:08:09,260 --> 00:08:10,610
Let's see what is happening here.

126
00:08:10,640 --> 00:08:16,040
So suppose initially, let's say the size of the vector is basically two.

127
00:08:16,250 --> 00:08:22,820
Let's say initially it is to let us assume it is not to actually but let us assume the size of the initial

128
00:08:22,820 --> 00:08:23,920
vector is basically two.

129
00:08:24,500 --> 00:08:27,780
So that means this, that this line will create a vector size two.

130
00:08:28,100 --> 00:08:29,030
So what is happening?

131
00:08:30,100 --> 00:08:31,060
This is my vector.

132
00:08:32,650 --> 00:08:38,740
Bush, then I can push down, then I'm pushing 20 so I can push 20, then in order to push 30, what

133
00:08:38,740 --> 00:08:43,750
will happen the size that will become double the size, the vector is basically four.

134
00:08:44,560 --> 00:08:48,640
So you can push the 30 element and you can push one more element.

135
00:08:49,690 --> 00:08:52,270
You can push one more element, the size of the vector is four.

136
00:08:53,060 --> 00:08:55,320
Now what I'm doing here change the second element.

137
00:08:55,330 --> 00:08:56,380
So this is 100.

138
00:08:58,130 --> 00:08:58,980
Now print.

139
00:08:59,210 --> 00:09:05,210
OK, now what they are doing, you are pushing the fourth element, so fourth element will be one zero

140
00:09:05,210 --> 00:09:08,270
zero two, but you are pushing the fifth element.

141
00:09:08,660 --> 00:09:10,160
So this is the fifth element.

142
00:09:11,420 --> 00:09:14,720
And at this memory, you are pushing one, two, three, four.

143
00:09:15,940 --> 00:09:22,060
So basically, my vector only has this much amount of memory, so this memory.

144
00:09:23,070 --> 00:09:24,320
Does not belong to me.

145
00:09:25,560 --> 00:09:31,530
So this memory does not belong to us, so basically you are pushing an element, you are pushing an

146
00:09:31,530 --> 00:09:35,910
element at such a memory location and that location does not belong to us.

147
00:09:36,240 --> 00:09:37,890
OK, so this is basically wrong.

148
00:09:38,870 --> 00:09:44,180
And this is also wrong, so let us experiment or something, so let us experiment something.

149
00:09:45,460 --> 00:09:51,790
So after pushing at fourth and fifth in Texas, let us push more elements so we don't push back.

150
00:09:53,760 --> 00:09:55,950
That said, 23 and let's see.

151
00:09:57,110 --> 00:09:57,530
Bush.

152
00:10:02,850 --> 00:10:05,340
OK, so now let us pretend everything's so.

153
00:10:25,130 --> 00:10:27,920
OK, so if I will run my program, which would be my output.

154
00:10:29,620 --> 00:10:31,670
So ideally, what should be our output?

155
00:10:32,260 --> 00:10:39,040
So initially I have pushed 10, then 20, then 30, then I change its value to 100, then I am pushing.

156
00:10:40,010 --> 00:10:47,150
So one zero zero two and then I'm pushing one, two, three, four, and then we don't push back 23

157
00:10:47,150 --> 00:10:49,580
and we don't push back to 34.

158
00:10:50,970 --> 00:10:56,070
So if I will execute our gold, there should be more output, ideally, there should be an output.

159
00:10:57,380 --> 00:11:03,080
OK, so please remember ten hundred thirty one zero zero two one, two, three, four, and then this

160
00:11:03,080 --> 00:11:03,290
one.

161
00:11:03,680 --> 00:11:06,460
So let's see where their output is, correct or not.

162
00:11:08,030 --> 00:11:09,170
Let's delete this one.

163
00:11:14,150 --> 00:11:15,500
So order to start our program.

164
00:11:19,120 --> 00:11:25,790
So this is the output, so let's see whether our output was wrong or right, so as discussed.

165
00:11:26,020 --> 00:11:27,890
So ideally, what should be at output?

166
00:11:27,910 --> 00:11:32,460
So when I pushed, I pushed Ben, then pushed, wanted and pushed hard, didn't change its value.

167
00:11:32,470 --> 00:11:32,980
Two hundred.

168
00:11:33,490 --> 00:11:38,730
Then I pushed using the square brackets, one zero zero two and one, two, three, four.

169
00:11:38,980 --> 00:11:45,160
And then I use push back function to insert two, three, four and so twenty three and two, three,

170
00:11:45,160 --> 00:11:45,410
four.

171
00:11:46,630 --> 00:11:54,190
So I leave my output with this one, but obviously this is, our idle output is not coming out.

172
00:11:54,220 --> 00:11:55,020
So what is happening.

173
00:11:55,330 --> 00:12:00,190
So when you are using function to insert these elements, what push back function will do, it will

174
00:12:00,190 --> 00:12:01,790
push the element at the last.

175
00:12:02,050 --> 00:12:07,990
So far this is the last 30 is the last because we didn't use push back function to insert these two

176
00:12:07,990 --> 00:12:08,460
elements.

177
00:12:09,670 --> 00:12:14,040
We do not use push back function to insert these two elements, so forth, push back function.

178
00:12:14,650 --> 00:12:16,060
This is the last index.

179
00:12:16,330 --> 00:12:17,170
So what will happen.

180
00:12:17,840 --> 00:12:21,240
Merchantmen output, Ben, then hundred, then 30.

181
00:12:21,610 --> 00:12:27,400
So basically twenty three will come here and then two, three, four, two, two, three, four.

182
00:12:28,690 --> 00:12:29,680
And then basically.

183
00:12:31,940 --> 00:12:33,800
So these two are removed.

184
00:12:35,440 --> 00:12:41,260
And then what is happening so so these two are basically lost, then I'm accessing this memory location

185
00:12:41,260 --> 00:12:43,270
and then I'm accessing this memory location.

186
00:12:43,510 --> 00:12:46,390
So these memory locations are basically garbage values.

187
00:12:47,540 --> 00:12:51,050
And in our case, these two garbage values are basically 090.

188
00:12:51,560 --> 00:12:55,510
So these two garbage values are basically zero and zero.

189
00:12:55,850 --> 00:12:59,190
It could have been anything but in our case, they both are zero.

190
00:12:59,870 --> 00:13:04,010
So that's why you should not you should never use brackets to insult.

191
00:13:04,010 --> 00:13:05,870
You should always use push back function.

192
00:13:08,620 --> 00:13:09,480
Now, one more thing.

193
00:13:10,670 --> 00:13:11,480
So basically.

194
00:13:13,740 --> 00:13:21,090
So basically how this function is able to access the sixth element and similarly the fifth element.

195
00:13:22,100 --> 00:13:26,150
This is able to access the sixth element because what it will do so it will say.

196
00:13:27,710 --> 00:13:33,740
So underlying this is my underlying Eddie, so it will go to its start address, it will take six jumps

197
00:13:33,740 --> 00:13:37,700
ahead and it will print whatever is present at this garbage location.

198
00:13:37,940 --> 00:13:39,060
So zero is present.

199
00:13:39,110 --> 00:13:40,730
That's why zero is getting printed.

200
00:13:41,750 --> 00:13:49,280
Simple, now I have itinerate of using this square because the alternate is basically afunction, the

201
00:13:49,280 --> 00:13:54,710
alternators basically Yusoff add function, so let's see how we can use add function and what is the

202
00:13:54,710 --> 00:13:57,170
difference between the add function and the square brackets?

203
00:13:59,780 --> 00:14:02,960
So one thing is quite clear here, this is very wrong.

204
00:14:04,520 --> 00:14:06,170
So never use.

205
00:14:07,640 --> 00:14:15,320
Square brackets to insert elements, because the size of the array will not increase, the size of the

206
00:14:15,320 --> 00:14:17,840
vector will not increase, the size will not become double.

207
00:14:18,140 --> 00:14:19,070
So this is wrong.

208
00:14:24,060 --> 00:14:25,890
Now, let us use add function.

209
00:14:28,730 --> 00:14:29,600
So, obviously.

210
00:14:31,400 --> 00:14:33,830
Let's remove this one, let's comment out everything.

211
00:14:36,240 --> 00:14:41,970
So I want to add function, so currently I have three elements and then two elements here, so the size

212
00:14:41,970 --> 00:14:43,500
of the vector is basically five.

213
00:14:46,830 --> 00:14:54,630
So, Scott, we don't at all function will take index, so let us print what is present at the index

214
00:14:54,630 --> 00:14:54,930
for.

215
00:14:56,890 --> 00:15:00,850
And let us also check what is present at next week's.

216
00:15:03,720 --> 00:15:06,180
So basically, index four is a valid index.

217
00:15:07,430 --> 00:15:12,350
The size of the event is currently five, so the last index is basically four, so this is actually

218
00:15:12,470 --> 00:15:15,410
a valid index, but index six is not valid.

219
00:15:16,070 --> 00:15:18,190
Index six is not a valid index.

220
00:15:19,280 --> 00:15:22,070
So if we will run our program, let's see what will be our output.

221
00:15:25,050 --> 00:15:26,490
So we'll see what is the output.

222
00:15:28,640 --> 00:15:34,370
So at the next four to three for this president, but at the next six, which is not a valid index,

223
00:15:34,370 --> 00:15:40,570
you can see out of range the size of the is basically five and you are trying to access the sixth element.

224
00:15:40,850 --> 00:15:42,700
So basically it is giving us added.

225
00:15:43,500 --> 00:15:45,100
It is giving us added.

226
00:15:45,410 --> 00:15:47,120
So what we can say.

227
00:15:48,140 --> 00:15:56,150
So this ad function, it basically checks whether the index is valid or invalid.

228
00:15:56,870 --> 00:16:03,670
So basically we can see that using the ADD function is much, much safer than using this square bracket.

229
00:16:03,830 --> 00:16:06,860
So it is much, much safer because it will check the index.

230
00:16:07,910 --> 00:16:13,760
If you will, so if you will, right without attic's, it will give us error that the size of the vector

231
00:16:13,760 --> 00:16:16,750
is basically five and you and you cannot access indexes.

232
00:16:17,240 --> 00:16:20,240
But if we will use the square, because then what will happen?

233
00:16:20,630 --> 00:16:22,150
It will go just like an error.

234
00:16:22,160 --> 00:16:23,600
It will go to the starting position.

235
00:16:23,880 --> 00:16:28,730
It will take six jumps ahead and it will print out everything, whatever it is present.

236
00:16:29,030 --> 00:16:30,620
So the output will be garbage.

237
00:16:32,140 --> 00:16:33,160
Now, which one is better?

238
00:16:33,400 --> 00:16:39,040
So obviously this memory does not belong to us, so this is basically very bad.

239
00:16:39,250 --> 00:16:40,610
Obviously, this is much better.

240
00:16:40,840 --> 00:16:41,980
So this is much safer.

241
00:16:41,980 --> 00:16:43,600
Using that function is safer.

242
00:16:44,050 --> 00:16:44,890
OK, so.

243
00:16:46,260 --> 00:16:49,900
So now let us use for Loop who our director.

244
00:16:49,920 --> 00:16:52,860
So how we can use for Loop, so let us comment about everything.

245
00:16:56,130 --> 00:16:58,140
So let's use for loop.

246
00:16:59,270 --> 00:17:05,079
So just like we used to, outraged over the area, we can also treat all the victims Y equals zero aliens,

247
00:17:05,150 --> 00:17:06,290
then we Nazis.

248
00:17:07,540 --> 00:17:12,010
Now, Vidaurre says this is inbuilt function or do you give me how many elements are present inside

249
00:17:12,010 --> 00:17:12,460
the vector?

250
00:17:12,460 --> 00:17:16,270
So currently five elements are present, so the value of your size is five.

251
00:17:17,349 --> 00:17:25,750
And here you can use Wi-Fi and here you can use the square brackets and you can use add.

252
00:17:25,930 --> 00:17:29,740
So at this so inside the for loop both.

253
00:17:29,860 --> 00:17:35,320
You can use both, you can use square beckert and you can also use and they both have same way because

254
00:17:35,320 --> 00:17:41,280
index is always valid because of the broad size will be five here inside the loop.

255
00:17:41,710 --> 00:17:45,880
It is safe to use both square because as well as the function Mutassim.

256
00:17:47,660 --> 00:17:52,580
So if you run the program where we are output, it will print the content of the vector.

257
00:17:55,110 --> 00:17:58,470
So this is the content then handed today, 23 and 24.

258
00:17:59,730 --> 00:18:06,120
So now we know how to edit it, the vector, so just like the push back function, I also have back.

259
00:18:07,220 --> 00:18:11,090
So what Bob function will do, so we get Bob back.

260
00:18:15,540 --> 00:18:19,240
So function what it will do, so it will pop out the last element.

261
00:18:20,550 --> 00:18:21,990
So what is the use of push back?

262
00:18:23,390 --> 00:18:28,650
Bush will insert the element at last and Bob will remove the last element.

263
00:18:29,060 --> 00:18:31,470
So basically this was the last element two, three, four.

264
00:18:31,490 --> 00:18:34,940
So this element will be removed and the director will become four.

265
00:18:34,950 --> 00:18:36,750
So four elements will be printed.

266
00:18:36,770 --> 00:18:37,250
Let's see.

267
00:18:43,400 --> 00:18:48,110
So what elements are getting printed the size, the effect is containing only four elements.

268
00:18:53,000 --> 00:18:56,840
Now, let's go find out everything and let's do some experiments.

269
00:19:02,480 --> 00:19:06,350
So let us use a follow up to insert the elements inside director.

270
00:19:07,650 --> 00:19:10,790
So let's say I want to push hundred elements.

271
00:19:11,800 --> 00:19:13,510
So let us push a hundred elements.

272
00:19:14,510 --> 00:19:16,610
So we not push back.

273
00:19:19,650 --> 00:19:20,490
Iblis one.

274
00:19:21,960 --> 00:19:26,760
So I am pushing a hundred elements and let us also print out our vector.

275
00:19:29,040 --> 00:19:32,640
So I was zero, I lived in brasses.

276
00:19:34,790 --> 00:19:35,840
And I placeless.

277
00:19:39,500 --> 00:19:40,550
CLV OWFI.

278
00:19:43,740 --> 00:19:49,650
So I am pushing a hundred elements and then I am printing those 100 elements simple, see?

279
00:19:54,170 --> 00:20:00,410
So these are the elements inserted starting from one 800, so, yes, it is working fine.

280
00:20:01,810 --> 00:20:03,010
Now, let us see.

281
00:20:04,190 --> 00:20:10,280
Now, let us also print the size, so when I'm pushing the limits, let us also print the size of the

282
00:20:10,280 --> 00:20:14,300
vector so we don't size.

283
00:20:17,590 --> 00:20:18,940
Now, what should be our output?

284
00:20:20,580 --> 00:20:27,510
What we don't say is will contain so the site function first, it will contain one element, then it

285
00:20:27,510 --> 00:20:29,350
will contain two, then three, then four.

286
00:20:29,490 --> 00:20:32,700
So basically this report says it will increase linearly.

287
00:20:33,570 --> 00:20:36,870
And finally, the size of the vector will become simple.

288
00:20:37,770 --> 00:20:39,900
There should be allowed output one 200.

289
00:20:40,930 --> 00:20:46,600
The size, the door size, so the size the vector will increase one by one simple.

290
00:20:47,980 --> 00:20:49,300
So let's remove this thing.

291
00:20:51,460 --> 00:20:53,380
And now we are only printing the size.

292
00:20:54,700 --> 00:20:57,130
So let us also right here.

293
00:20:58,470 --> 00:20:59,850
What is the size of the vector?

294
00:21:02,940 --> 00:21:04,560
And let's give and also.

295
00:21:06,780 --> 00:21:07,530
So let's see.

296
00:21:11,100 --> 00:21:11,820
So you can see.

297
00:21:12,880 --> 00:21:17,670
When Bush Winnellie undersize will become one, when you push the second element, the size becomes

298
00:21:17,680 --> 00:21:17,910
too.

299
00:21:18,130 --> 00:21:21,020
When you push the third element, the size becomes three and so on.

300
00:21:21,310 --> 00:21:27,220
And finally, when you will push the limit, the size of the vector will become simple.

301
00:21:28,720 --> 00:21:31,690
Now, we also have a functioning capacity.

302
00:21:32,810 --> 00:21:39,200
So our function capacity, so what this capacity function will do, so it will give me what is the capacity,

303
00:21:39,200 --> 00:21:41,390
what is the current capacity of my vector?

304
00:21:42,650 --> 00:21:49,190
It will give me what is the current capacity of my vector and the difference between capacity and sizes,

305
00:21:49,790 --> 00:21:52,160
size will give me how many elements are present.

306
00:21:52,190 --> 00:21:55,570
So, for example, let's say three elements are present.

307
00:21:55,610 --> 00:21:57,190
All sides will give me that.

308
00:21:57,250 --> 00:22:02,180
Three elements that present various capacity will give me how many elements you can insert inside the

309
00:22:02,180 --> 00:22:04,570
vector, for example, for example, six.

310
00:22:04,610 --> 00:22:06,500
So the capacity will be six.

311
00:22:07,370 --> 00:22:10,250
Now let us print, but we will print capacity and size.

312
00:22:10,910 --> 00:22:16,610
And ideally what should happen so that capacity will become double capacity will become double as soon

313
00:22:16,610 --> 00:22:17,920
as the vector is full.

314
00:22:18,380 --> 00:22:19,610
So let's check it out.

315
00:22:23,860 --> 00:22:25,750
So let us bring the capacity.

316
00:22:32,680 --> 00:22:33,010
Don't.

317
00:22:34,270 --> 00:22:39,790
Capacity, so this is also a function function of basically Victor.

318
00:22:40,760 --> 00:22:42,830
And let's remove sales from here.

319
00:22:50,790 --> 00:22:53,820
OK, so let's go and let's see what will happen.

320
00:23:00,910 --> 00:23:02,930
So let us try to understand what is happening here.

321
00:23:03,340 --> 00:23:07,940
So initially the capacity is zero and the size is also zero.

322
00:23:08,560 --> 00:23:10,350
Strange area of size zero.

323
00:23:10,720 --> 00:23:18,190
So basically this means that starting added, we don't really exist and is basically does not exist.

324
00:23:18,640 --> 00:23:24,220
When you push the first element, the capacity becomes one and the size becomes two when you will push.

325
00:23:24,640 --> 00:23:25,990
So this is the first element.

326
00:23:27,070 --> 00:23:32,590
The capacity is one and the size is one, so when you will push the second element, the capacity will

327
00:23:32,590 --> 00:23:33,240
become twice.

328
00:23:33,280 --> 00:23:34,600
So this is the capacity.

329
00:23:34,600 --> 00:23:36,730
Capacity becomes too, and size is also, too.

330
00:23:37,720 --> 00:23:43,330
When you will push the third element, the capacity will become for the size will become double, the

331
00:23:43,330 --> 00:23:46,030
capacity will become double the size of actors basically follow.

332
00:23:46,840 --> 00:23:49,740
So you can push the fourth element and the capacity is still four.

333
00:23:50,470 --> 00:23:54,810
But when you are pushing the fifth element, the capacity becomes available.

334
00:23:54,820 --> 00:23:55,780
So the capacity.

335
00:23:57,170 --> 00:24:03,740
It's basically the vector capacities it, so you can safely push element six, you can push element

336
00:24:03,760 --> 00:24:05,240
seven, you can push limited.

337
00:24:05,480 --> 00:24:09,130
But when you're trying to push the ninth element, the capacity doubles.

338
00:24:09,710 --> 00:24:12,290
So it will become 16.

339
00:24:12,920 --> 00:24:17,090
So you can push 10, 11, 12, 13, 14 and so on.

340
00:24:17,360 --> 00:24:20,870
So finally, when you trying to push the 17th element.

341
00:24:22,010 --> 00:24:25,460
Capacity will become 32 and so on, so it will keep going on.

342
00:24:26,930 --> 00:24:28,610
So finally, let's see.

343
00:24:30,920 --> 00:24:40,370
So finally, the capacity is 128 and this is enough to hold 100 elements, so capacity 128 is enough

344
00:24:40,370 --> 00:24:42,170
to hold these many number of elements.

345
00:24:44,480 --> 00:24:50,930
OK, so we have seen how to create bestriding and dynamically we know how to push elements, we know

346
00:24:50,930 --> 00:24:53,060
the capacity function, we know the same function.

347
00:24:54,760 --> 00:24:59,960
We know the pop back function, so this one Vidarbha back, we know how to pop element.

348
00:24:59,980 --> 00:25:01,270
We know how to push element.

349
00:25:01,660 --> 00:25:03,550
We know how to change the elements.

350
00:25:04,880 --> 00:25:11,210
We know how to get rid of a director, so pretty much we know all the major functions of director.

351
00:25:12,130 --> 00:25:16,960
OK, so one last thing, how to create a better offer given, say, for example.

352
00:25:18,300 --> 00:25:25,320
I want to create a vector, let's say, of size 10, so you can give size here to giving sizes optional

353
00:25:25,410 --> 00:25:26,990
if you want to give the size you can.

354
00:25:27,000 --> 00:25:28,800
If you don't want to give, then don't give.

355
00:25:30,280 --> 00:25:37,090
OK, so what if you want to initialize this vector, so comma, let's say I want to ask this vector

356
00:25:37,090 --> 00:25:37,870
with minus two.

357
00:25:39,080 --> 00:25:43,820
So this victory has been neutralized all the time, values are basically minus two.

358
00:25:43,850 --> 00:25:50,240
You can also see so let Sprent distractor, OK, let's change the name to.

359
00:25:51,520 --> 00:25:55,660
So equals zero, iList, and we do.

360
00:25:56,600 --> 00:25:57,530
I placeless.

361
00:25:59,440 --> 00:26:00,520
And to see out.

362
00:26:03,470 --> 00:26:03,980
Symbol.

363
00:26:08,020 --> 00:26:09,940
OK, so we do our site.

364
00:26:21,370 --> 00:26:21,910
Solice.

365
00:26:22,950 --> 00:26:29,010
The vector has been analyzed, all the elements are minus two, so that's how you initialize the vector.

366
00:26:33,140 --> 00:26:37,070
So it is not necessary to initiate the victor, so if you're right like this.

367
00:26:38,600 --> 00:26:44,510
Rector of Indigenous Vetri, and you can only give size, so this is also correct.

368
00:26:45,050 --> 00:26:45,950
OK, so.

369
00:26:46,910 --> 00:26:50,530
Can we start the victor, so, yes, we can, SA Director.

370
00:26:50,990 --> 00:26:53,690
I haven't malfunctions, Art, so what we will do.

371
00:26:54,850 --> 00:26:58,530
I will write like this, for example, I want to start victory to.

372
00:26:59,290 --> 00:27:00,310
We do not begin.

373
00:27:03,280 --> 00:27:08,700
We do not and so just like Eddie, we have to give the starting in the end outrageous.

374
00:27:09,130 --> 00:27:13,240
So I thought we would not begin and we do not end and my victory will become sorted.

375
00:27:14,460 --> 00:27:21,060
My victory will be sorted, OK, so we know how to initialize, we know how to give, how to create

376
00:27:21,060 --> 00:27:22,320
a bit of a given size.

377
00:27:23,430 --> 00:27:29,100
We know how to sort of act so pretty much we know all the functions, all the major functions of the

378
00:27:29,100 --> 00:27:29,520
vector.

379
00:27:30,660 --> 00:27:35,490
OK, so I think this is enough, I will see you in the next one, bye bye.

