ProgrammingModerate

A matrix of 3000 x 3000 cells is read once and each cell is visited a constant number of times. Which complexity bound applies to the whole job?

  1. A. O(27 x 10^9), which is cubic in the side length
  2. B. O(9 x 10^6), which is linear in the number of cells
  3. C. O(3000^4), which is quartic
  4. D. O(log 9 x 10^6), which is logarithmic

Correct answer: B. O(9 x 10^6), which is linear in the number of cells

The work is proportional to the cell count, 9 x 10^6. Cubic or quartic bounds apply only when each cell is combined with many others.

More C Programming questions

Exams that ask this topic