CSE116 / CSE504 Introduction to Computer Science II Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu Office hours: Thursday 12:00 PM – 2:00 PM Friday 8:30 AM – 10:30 AM OR request appointment via e-mail PROFESSIONALISM Turn off and put away electronics: cell phones pagers laptops tablets etc. © Dr. Carl Alphonce ROADMAP Last class java.util.LinkedList exercise: remove Today asymptotic notation Friday exam Q&A session (bring questions!) Exam #1 EXAM INFORMATION Tuesday 3/8, 9:15 PM - 10:15 PM Will cover material up to 2/26 (as well as WU3) If you have a legitimate conflict (work/school): get documentation, scan it as a PDF e-mail it to me with subject line: [CSE116] Exam 1 conflict documentation NO LATER THAN 5:00 PM on 3/4 (FRIDAY) WEDNESDAY 3/9 IS EXAM MAKE-UP DAY: NO REGULAR LECTURE © Dr. Carl Alphonce Big Oh notation Let g be a function that has non-negative integer arguments and returns a non-negative value for all arguments. A function f is said to be O(g) if for some positive constant C and some non-negative constant K, f(n) <= C g(n), for all n > K READ: CHAPTER 3 OF TEXTBOOK Exercise (see textbook, work out on your own) What is performance of operations on data structures we have seen so far? operations: add (find, insert, resize?) contains (find) remove (find, remove, resize?) data structures Bag ArrayList LinkedList / LRStruct Stack Queue Worst-case behavior We can measure behavior of an algorithm in the best case (often not interesting) average case (often most meaningful, but hard to characterize and measure) worst case (meaningful, easy to characterize and measure) MultiSet of size n worst-case insert O(n) contains O(n) remove O(n) ArrayList of size n worst-case insert (at specific location) (must search for location) O(n) O(n) contains O(n) remove (at specific location) (must search for location) O(n) O(n) LinkedList of size n worst-case insert (at specific location) (must search for location) O(1) O(n) contains O(n) remove (at specific location) (must search for location) O(1) O(n)