Se está descargando tu SlideShare. ×

Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Cargando en…3
×

1 de 2 Anuncio

# Use the code below to answer questions 1 through 3- What is the time c.docx

Use the code below to answer questions 1 through 3:
What is the time complexity of silly1 (give tightest big O)?
What is the time complexity of silly2 (give tightest big O)?
What is the time complexity of silly3 (give tightest big O)?
public static void silly1(int n) t for (int i = 0; i 0) t System.out.println(\"j - \"j); public static void silly2(int n) for (int k = n; k > 0; k--){ for (int i = 0; i
Solution
1 ANS::: for loop run N times
while loop run N+1 TIMES
TOTAL N(N+1)=N^2+N = O(N^2);
2 ANS::::::
N+1 * N *N=O(N^3)
3 ANS:::::
HERE 1ST FOR LOOP N+1 TIMES
AND ADD 2ND LOOP N TIMES
TOTAL N+1+N=O(N)
.

Use the code below to answer questions 1 through 3:
What is the time complexity of silly1 (give tightest big O)?
What is the time complexity of silly2 (give tightest big O)?
What is the time complexity of silly3 (give tightest big O)?
public static void silly1(int n) t for (int i = 0; i 0) t System.out.println(\"j - \"j); public static void silly2(int n) for (int k = n; k > 0; k--){ for (int i = 0; i
Solution
1 ANS::: for loop run N times
while loop run N+1 TIMES
TOTAL N(N+1)=N^2+N = O(N^2);
2 ANS::::::
N+1 * N *N=O(N^3)
3 ANS:::::
HERE 1ST FOR LOOP N+1 TIMES
AND ADD 2ND LOOP N TIMES
TOTAL N+1+N=O(N)
.

Anuncio
Anuncio