def f(n): i = 0 while i < n: j = 0 while j < 1000: print(str(i) + ", " + str(j)) j += 1 i += 1 2: c_1 3, 4, 8: c_2 5, 6, 7: c_3 Line 2, run one time. Lines 3, 4, 8, run n times. Lines 5, 6, 7, run 1000 times for each execution of the outer loop, so 1000n times. Runtime is c_1 + c_2 n + c_3 1000 n or Theta(n)