Download presentation
Presentation is loading. Please wait.
1
TUTORIAL 9 CS 137 F18 November 13th
2
Overview a6 Common Mistakes a7 Progress a8 Hints Big Oh Practice
3
a6 Common Mistakes a6p1: euclidean_algorithm.c a6p2: run.c
Divide by zero a6p2: run.c Printing the final character a6p3: merge.c Overall very well done sort immediately
4
a7 Progress? Questions? A7p2: num_duplicates.c A7p3: largest_square.c
Add a case for the NULL string! Array type makes sense A7p3: largest_square.c Easy to find a square Trouble finding the largest
5
a8 Hints Questions? MUST remove main function (comment or delete)
Start as soon as it is covered in lecture a8p1: multipleChoice.c Taking the most recent submission a8p2: insert_or_merge.c Use print statements; remove them before you submit Can change anything besides the problem’s function inputs; do not go crazy a7p3: sum_to_zero.c Use an efficient sort AND an efficient comparison; no nested for loops Stress test case topic
6
Big O Notation Most efficient O(1) Constant time O(log(n))
a means for measuring the time efficiency of an algorithm based on the number of inputs, n Most efficient O(1) Constant time O(log(n)) Logarithmic time O(n) Linear time O(n*log(n)) Linearithmic time O(n2) Quadratic time O(nc) (c > 2) Polynomial time O(cn) (c > 1) Exponential time Least efficient O(n!) Factorial time
8
Which of the following is ordered correctly from most efficient to least?
A) O(1), O(logn), O(n), O(nlogn), O(n4), O(nn), O(cn), O(n!) B) O(1), O(nlogn), O(n), O(logn), O(n4), O(cn), O(n!), O(nn) C) O(1), O(logn), O(n), O(nlogn), O(n4), O(cn), O(n!), O(nn) D) O(nn), O(n!), O(cn), O(n4), O(logn), O(n), O(nlogn), O(1) E) None of the Above
9
26 is O(1) A) True B) False
10
53n2 + 2n3 + 4n is O(n2) A) True B) False
11
n + log(n) is O(n) A) True B) False
12
2n + n100 is O(2100) A) True B) False
13
4n4 + 2n2 is: A) O(n2) B) O(n4) C) O(en) D) All of the Above.
E) Only B and C
14
9n*log(n) + 5n2 is O(n*log(n))
A) True B) False
15
n2 + 3n5 + 5n + 4n3 + 2 is O(2n) A) True B) False
16
n2 + 3n5 + 5n + 4n3 + 2 is O(1n) A) True B) False
17
Examples see examplesBigOh.zip
Set your clicker back to classroom’s ID: BD
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.