When the size of a program's input is increased by a factor of 2 (n*2), the runtime increases by a factor of 8 (t*8). The program is:

  • A: O(n)
  • B: O(n log n)
  • C: O(n2)
  • D: O(n3)
  • E: O(2n)

    Answer: D

    When the input size increases by 2 and the time increases by x, the Big O is O(nk) where x = 2k. In this case, 8 = 23, so the program is O(n3).

    Prev    Next    Page+10