{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

nootes71

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

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

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.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• 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.

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

• 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.

Dana University of Pennsylvania ‘17, Course Hero Intern

• 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.

Jill Tulane University ‘16, Course Hero Intern