CSC300 / CSC402: What's the result? [3/13] Previous pageContentsNext page

01
02
03
04
05
06
    for (long i = N; i > 0; i = i-1) {
      result = result+1;
    }
    for (long j = N; j > 0; j = j-1) {
      result = result+1;
    }

Choices:

  1. independent of N -- constant
  2. ~ lg N -- logarithmic
  3. ~ (lg N)^2 -- log squared
  4. ~ N -- linear
  5. ~ 2N -- linear
  6. ~ N(lg N) -- linearithmic
  7. ~ (N^2)/2 -- quadratic
  8. ~ N^2 -- quadratic
  9. ~ N^3 -- cubic
  10. ~ 2^N -- exponential

Previous pageContentsNext page