Can someone explain the following space complexity calculation to me?
Given a stream of numbers of size b bits, calculate the sum of these numbers.
If we have seen T numbers so far, the sum is at most T2^b and hence needs at most O(b+log T) space.
Now, T2^b must be an upper bound because a more accurate upper bound would be T(2^b - 1).
But how did they calculate that the space upper bound is O(b +logT)?
With m bits, you can store numbers up to (about) 2m. So, working the other way, if you know the sum, you need to take a logarithm to get the number of bits (and hence the space complexity).
Here, log(T 2b) = b + log(T).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With