Vectors Quiz Que 3

How come the complexity to get the sum by the recursive function shows the solution as O(N^2). I believe it should be O(N). Should I go with the error maybe with the answer.

hello @chebomsta

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) .

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.