Question

What is the Big-Oh order of the following code fragment? The size of the problem is expressed as n.

for (int i = 0; i < (int)Math.pow(2, n); i++)

System.out.println("what could could go wrong?"); //f(n) counts these

EXPERT ANSWER

Here the loop will run {eq}2^n

{/eq} times depending on the value of n. So the the Big-Oh Order will be {eq}O(2^n)

{/eq}

## We are so grateful for the pleasure