Hi, everyone. Anybody can show me how to write a nested for loop about 3^n?

Thanks!

Printable View

- 06-25-2013, 08:16 AMhjxlpptime complexity about 3^n using nested for loop
Hi, everyone. Anybody can show me how to write a nested for loop about 3^n?

Thanks! - 06-25-2013, 09:26 AMJosAHRe: time complexity about 3^n using nested for loop
Sure, have a look:

Code:`void bigOh(int n) {`

int t= (int)Math.pow(3, n);

for (int o= 1; o == 1; o++) // outer loop

while (t-- > 0); // nested loop

}

Jos