is this true that always a vector doubles it size even if it wants to add only one single element.
or does it just increases the size acc to requirement
Memory allocation in a vector
Hi @asaraf2407,
it is true that vector double its size but it only does so when required.
suppose vector initially is v={1,2,3}.
so1)capacity=4, size=3, so we can push 1 more element without doubling its size.
2)capacity=4,size=4, so now we will have to double its capacity if we have to insert more elements.
hope dis resolves ur doubt.
if u still hv any doubt,post it here