-2

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

OmG
  • 18,337
  • 10
  • 57
  • 90
user472221
  • 3,014
  • 11
  • 35
  • 42

2 Answers2

0

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

mariana soffer
  • 1,853
  • 12
  • 17
0

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

Adam
  • 16,808
  • 7
  • 52
  • 98