Skip to content
Advertisement

Tag: space-complexity

Space complexity of the piece of code below?

I came across this question while I was doing some interview prep. The choices given were: O(n) O(n^2) From what I understand the answer should have been O(n) as on every iteration a new instance of the array is being created and the previous reference is being lost. However, the book mentions the answer to be O(n^2). What could be

Space Complexity of an array?

I have an array of size N, and N is <=200. What would be the space complexity here. O(1) or (N) – considering the constraint N. Answer Complexity is only relevant when you try to foresee the performances of your algorithm with various input. I don’t think it has any meaning to just speak about the space-complexity of an array

Advertisement