Question 3 of quiz vector stl, why it is taking O(N^2)?

why the time complexity is O(N^2) not O(N).

hello @aadity_patel13
pls share the question with me

Predict the time complexity of the following recursive function, given the vector is of size N and the initial call is calSum(v, 0). int sum = 0; void calcSum(vector v, int i) { if(i == v.size()) return; sum += v[i]; calcSum(v, i+1); }

since the vector is being passed by value, it will be copied to a new vector in each call. Copying the vector will take O(n) time, doing so n times will make the overall time complexity of the program as O(n*n)