Diese Präsentation wurde erfolgreich gemeldet.
Die SlideShare-Präsentation wird heruntergeladen. ×

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

Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige

Hier ansehen

1 von 2 Anzeige

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

Herunterladen, um offline zu lesen

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)
.

Anzeige
Anzeige

Weitere Verwandte Inhalte

Weitere von rtodd63 (20)

Aktuellste (20)

Anzeige

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

  1. 1. 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)

×