C++ stl quiz 2 :(Q3. Vector STL#3)

how the program will take o(n^2) ???

hello @Vijay-Gwala-1537851266358174
assuming vector is defined as vector< int > v
its time complexity will be O(n^2).
because total n calls wiil be there and on every call vector get copied to new vector which is O(n) for each call . therefore O(n^2) for n calls

1 Like

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.