Vector capacity issue

when we remove the elements to half of the initial elements using pop back does vector capacity decreases?

one more doubt does clear function also remove the memory allocated to vector or just remove the elements

Hi @Rj.25
When you pop element from vector its capacity remains the same.
Clear function only removes the element, it does not remove the memory allocated.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.