How comes O(N^2)?

how O(N^2)? Please explain

hello @chitwan_manchanda
Assumming 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
Its not passed by reference but by copy
so for each recursive call a copy of vector is made
So rec reln in terms of time complexity is T(n)=T(n-1) + O(n) ==>T(n-2)+2 O(n) ==> T(1)+n O(n)==O(n^2)

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.