I have vector v, initial size = 10. pushed 10 element. while adding 11th element, it will dynamic grow the size (N = N*2) i.e. 20 element. Now vector has 11 element and can accommodate 20 element.
My question is if we delete a element from vector will any point vector capacity decreases from N = N/2 something just as it increase by N*2.if yes then what is strategy behind the deallocation of vector or shrinking. because as per above example if we delete 11th element it will shrink to 10 and again if we add 11th it will grow. if i keep adding and deleting 11th element it will keep allocating and allocate memory which is not good.
EDIT : if answer is no then for eg. 1000 element is added into vector and now 990 element has been popped out still it use space for 1000 element. Will it not be waste of memory?