I have a question that :
I have an array "S"
which has n
objects in it. also each object has m
fields.
I want to save some of them in the another array like "Q"
. I want to know that the space complexity of this easy method is O(|Q|)
?
I have a question that :
I have an array "S"
which has n
objects in it. also each object has m
fields.
I want to save some of them in the another array like "Q"
. I want to know that the space complexity of this easy method is O(|Q|)
?
The size of S it is n*sum(sizeofeach(m of n))
Then suppose you save r object where r<n
The size of q it is r*(sum(sizeofeach(m of r))
The space complexity is the amount of space required to store Q. Let s
be the size of one element in Q, i.e. s = size of all m fields
. The space complexity is O(n*s)
. If all fields are the same constant size then you could say O(n*m)
.