{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

nootes71 - Asymptotic Notation goal To simplify analysis by...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Asymptotic Notation goal: To simplify analysis by getting rid of unneeded info. - It also tells us how an algorithm scales up; that is: how it behaves with large inputs example: Execution time of an algorithm: 0.00001 * n^2 + 10n + 1000 = O(n^2) Special Classes of Algorithms O(1) = constant time, basic operations O(n) = linear time, sequential searches, traversals O(log n) = logarithmic time, binary searches, balanced trees O(nlog n) = no term, best sorting algorithms O(n^2) = quadratic time, bubble sort O(n^k) = polynomial time O(a^n) = exponential time, np-complete problems(traveling salesman, chess games) ... best solved by heuristic behaviors example: Obtain the complexity (asymptotic notation) of obtaining the maximum of an array of numbers. algorithm: arrayMax(int A[], int n); input: A -> an integer array n-> array length # of execution s : public int arrayMax( int A[], int n) { 1 int currentMax = A[0]; 1 int i; n-1 for (i=1; i < n ;i++) { n-1 if (currentMax < a[i]) { x < n-1 currentMax = A[i]; } } 1 return currentMax; } max execution time =< T0 + T1+ ( n-1 )T2 + ( n-1 )T3 + ( n-1 )T4 + T5 = O(n) example: Sort an array of n integers using bubble sort.
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ 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