Presentation is loading. Please wait.

Presentation is loading. Please wait.

Midterm review October 02, 2017 Geoffrey Tien.

Similar presentations


Presentation on theme: "Midterm review October 02, 2017 Geoffrey Tien."— Presentation transcript:

1 Midterm review October 02, 2017 Geoffrey Tien

2 Midterm 1 information October 04, in-class (50 minutes)
Closed book, closed notes C functions reference sheet provided (see course webpage for sample) Topics covered functions, parameters, arrays, loops, strings pointers & dynamic memory structures complexity / asymptotic analysis By now you should have received a GradeScope invitation to your CS ugrad Please check and set a password before the exam! Please remember your CS ugrad ID – you must write it on your exam October 02, 2017 Geoffrey Tien

3 From sample exam 1 Put these Big-O sets of functions into ascending order of complexity: 𝑂 𝑛 , 𝑂 log 𝑛 , 𝑂 𝑛 , 𝑂 𝑛 , 𝑂 1 𝑛 Solution at course website, but... A note about 𝑂 1 𝑛 Not really any practical algorithm with this running time – why? Think about this function's rate of "growth" October 02, 2017 Geoffrey Tien

4 From sample exam 1 void myCalc(int N) { int w, k; j = 0; n = N;
while (n > 1) n = n / 32; j++; } for (w = 0; w < (N/3 + 32); w++) for (k = 1; k <= j*N; k++) printf("$"); This determines how many times the inner loop runs October 02, 2017 Geoffrey Tien

5 Some other loop forms Find the most appropriate asymptotic running time of this function void lotsoloops(int n) { int i, j, k; for (i = 0; i < n; i = i+2) { if (i % 2 == 0) { for (j = 0; j < n; j = j*2) { for (k = n; k > 1; k = sqrt(k)) { printf("$"); } October 02, 2017 Geoffrey Tien

6 Some other loop forms What about this function? It looks almost the same void lotsoloops(int n) { int i, j, k; for (i = 0; i < n; i = i+2) { if (i % 2 == 1) { for (j = 0; j < n; j = j*2) { for (k = n; k > 1; k = sqrt(k)) { printf("$"); } October 02, 2017 Geoffrey Tien

7 Any more questions? Good luck! October 02, 2017 Geoffrey Tien


Download ppt "Midterm review October 02, 2017 Geoffrey Tien."

Similar presentations


Ads by Google