This is the code given in my algorithms book.We need to calculate its space complexity.
this is the answer given-
The space complexity is S=C+Sp
and in this case Sp
is zero as the code is independent of n
.
But I wanted to calculate the C part of the code and in this case it would be 5*2bytes=10 bytes
considering a,x,n,0 and -1.
So my question is what would be the C in case a was a 2d matrix,do we consider it as 2 bytes
only as in the case of 1d array or we take it as 4 bytes?