lec02-handout.pdf - Announcements CMPSCI 311 Introduction...

This preview shows 1 out of 2 pages.

CMPSCI 311: Introduction to Algorithms Lecture 2: Asymptotic Notation and Efficiency Akshay Krishnamurthy University of Massachusetts Last Compiled: January 24, 2018 Announcements: Homework 1 released (website, Moodle, Gradescope) No discussion on Friday Quiz 1 out on Friday Recap: Stable Matching Given n students and n colleges, each with preferences over the other. Can we find a stable matching? Stability: Don’t want to match c with s and c with s if c and s would prefer to switch to being matched with each other. Yes! Propose and Reject Algorithm. Algorithm terminates in n 2 iterations Everyone gets matched Resulting matching is stable! Big-O: Motivation What is the running time of this algorithm? How many “primitive steps” are executed for an input of size n ? sum = 0 for i = 1 to n do for j = 1 to n do sum += A [ i ] * A [ j ] end for end for The running time is T ( n ) = 3 n 2 + n + 1 . For large values of n , T ( n ) is less than some multiple of n 2 . We say T ( n ) is O ( n 2 ) and we typically don’t care about other terms. Big-O: Formal Definition Definition : The function T ( n ) is O ( f ( n )) if there exist constants c 0 and n 0 0 such that T ( n ) cf ( n ) for all n n 0 We say that f is an asymptotic upper bound for T . Examples : If T ( n ) = n 2 + 1000000 n then T ( n ) is O ( n 2 ) If T ( n ) = n 3 + n log n then T ( n ) is O ( n 3 ) If T ( n ) = 2 log n then T ( n ) is O ( n ) If T ( n ) = n 3 then T ( n ) is O ( n 4 ) but it’s also O ( n 3 ) , O ( n 5 ) etc.
Image of page 1

Subscribe to view the full document.

Image of page 2
You've reached the end of this preview.
  • Fall '09
  • Big-O Notation, Big O notation, Analysis of algorithms, Akshay Krishnamurthy

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern