nootes71

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

Info iconThis 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];
Background image of page 1

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

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

Page1 / 3

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

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online