# Problem of the Day

Monday, April 22, 2024

**Problem:**

Consider the following code segment, which prints out a series of asterisks.

int n = 3;

for (int i = 0; i < n; i++)

{

for (int j = 0; j < n; j++)

{

System.out.print("*");

}

}

What is the big-O performance of this code segment?

*O*(1) - constant*O*(n) - linear*O*(n^{2}) - quadratic*O*(2^{n}) - exponential

The correct answer is *c*. Nested loops such as this are often quadratic in nature, and thus not ideal for scaling up to large values of `n`

.