CS130-lecture-20200914

Annoucements #

New webcam usage survey

Exercise solutions:

IMAGE IMAGE IMAGE


Runtime analysis cont. #

IMAGE IMAGE IMAGE

Space complexity analysis #

IMAGE

1MB) kB

IMAGE IMAGE

Strings have the fields: start address, length, offset, hash

IMAGE

For example:

str = "Java";
str1);

IMAGE

The space is constant because the sub string isn’t copied, just more references are made.

IMAGE

  • c + 4n, so O(n)
  • IMAGE
  • 32 + 64n)

IMAGE IMAGE IMAGE

Normally you don’t count the space of the parameters or the return.

IMAGE IMAGE

Time complexity is O(n) Space complexity is O(1)