Space Complexity

If we are given a function in which we pass an array to the function. If we append one element to the array and delete one element from array(vector), Will it be be considered O(1) space or O(n) as at any time the size of the array is constant.

//Just a sample code for the idea
void fun (vector a)
{
for(i=0;i<a.size();i++)
a.push_back(a[0]);
erase(a.begin());
}

Comments (0)