Analysis of Algorithms Examples of functions important in









![Analysis of Algorithms [ Section 4. 2 ] How to analyze algorithms - Counting Analysis of Algorithms [ Section 4. 2 ] How to analyze algorithms - Counting](https://slidetodoc.com/presentation_image_h2/7021f5bbeb71d0ab5b0f98b36531758e/image-10.jpg)
![[ Section 4. 2. 3 ] Analysis of Algorithms Asymptotic notation Big-Oh notation: Let [ Section 4. 2. 3 ] Analysis of Algorithms Asymptotic notation Big-Oh notation: Let](https://slidetodoc.com/presentation_image_h2/7021f5bbeb71d0ab5b0f98b36531758e/image-11.jpg)



![[ Section 4. 2. 3 ] Analysis of Algorithms Asymptotic notation continued Big-Omega notation: [ Section 4. 2. 3 ] Analysis of Algorithms Asymptotic notation continued Big-Omega notation:](https://slidetodoc.com/presentation_image_h2/7021f5bbeb71d0ab5b0f98b36531758e/image-15.jpg)
![Analysis of Algorithms [ Section 4. 2. 3 ] Asymptotic notation continued Big-Theta notation: Analysis of Algorithms [ Section 4. 2. 3 ] Asymptotic notation continued Big-Theta notation:](https://slidetodoc.com/presentation_image_h2/7021f5bbeb71d0ab5b0f98b36531758e/image-16.jpg)
![Analysis of Algorithms [ Section 4. 2. 5 ] Words of caution: • what Analysis of Algorithms [ Section 4. 2. 5 ] Words of caution: • what](https://slidetodoc.com/presentation_image_h2/7021f5bbeb71d0ab5b0f98b36531758e/image-17.jpg)
- Slides: 17
Analysis of Algorithms Examples of functions important in CS: • the constant function: f(n) = [ Section 4. 1 ]
Analysis of Algorithms Examples of functions important in CS: • the constant function: f(n) = c • the logarithm function: f(n) = logb n [ Section 4. 1 ]
Analysis of Algorithms Examples of functions important in CS: • the constant function: f(n) = c • the logarithm function: f(n) = logb n • the linear function: f(n) = [ Section 4. 1 ]
Analysis of Algorithms Examples of functions important in CS: • the constant function: f(n) = c • the logarithm function: f(n) = logb n • the linear function: f(n) = n • the n-log-n function: f(n) = n log n [ Section 4. 1 ]
Analysis of Algorithms Examples of functions important in CS: • the constant function: f(n) = c • the logarithm function: f(n) = logb n • the linear function: f(n) = n • the n-log-n function: f(n) = n log n • the quadratic function: f(n) = n 2 [ Section 4. 1 ]
Analysis of Algorithms Examples of functions important in CS: • the constant function: f(n) = c • the logarithm function: f(n) = logb n • the linear function: f(n) = n • the n-log-n function: f(n) = n log n • the quadratic function: f(n) = n 2 • the cubic function and other polynomials f(n) = n 3 f(n) = [ Section 4. 1 ]
Analysis of Algorithms Examples of functions important in CS: • the constant function: f(n) = c • the logarithm function: f(n) = logb n • the linear function: f(n) = n • the n-log-n function: f(n) = n log n • the quadratic function: f(n) = n 2 • the cubic function and other polynomials f(n) = n 3 • the exponential function: f(n) = [ Section 4. 1 ]
Analysis of Algorithms Comparing growth rates • f(n) = c • f(n) = logb n • f(n) = n log n • f(n) = n 2 • f(n) = n 3 • f(n) = bn [ Section 4. 1 ]
Analysis of Algorithms How to analyze algorithms - Experimental studies [ Section 4. 2 ]
Analysis of Algorithms [ Section 4. 2 ] How to analyze algorithms - Counting the number of primitive operations Note: possible difference between the worst-case running time and the average-case running time
[ Section 4. 2. 3 ] Analysis of Algorithms Asymptotic notation Big-Oh notation: Let f(n) and g(n) be functions from integers to reals. We say that f(n) = O(g(n )) if there are constants c>0 and n 0>0 such that f(n) · c g(n) for every n ¸ n 0 We also say that f(n) is order of g(n).
Analysis of Algorithms Examples: f(n) = 5 n-3 g(n) = n [ Section 4. 2. 3 ]
Analysis of Algorithms Examples: f(n) = 7 n 2+(n 3)/5 g(n) = n 4 [ Section 4. 2. 3 ]
Analysis of Algorithms Examples: Insert-sort algorithm // input: array A, output: array A is sorted int i, j; int n = A. length; for (i=0; i<n-1; i++) { j = i; while ((j>=0) && (A[j+1]<A[j])) { int tmp = A[j+1]; A[j+1] = A[j]; A[j] = tmp; j--; } } [ Section 4. 2. 3 ]
[ Section 4. 2. 3 ] Analysis of Algorithms Asymptotic notation continued Big-Omega notation: Let f(n) and g(n) be functions from integers to reals. We say that f(n) = (g(n)) if there are constants c>0 and n 0>0 such that f(n) ¸ c g(n) for every n ¸ n 0
Analysis of Algorithms [ Section 4. 2. 3 ] Asymptotic notation continued Big-Theta notation: Let f(n) and g(n) be functions from integers to reals. We say that f(n) = £(g(n)) if f(n) = O(g(n)) and f(n) = (g(n)).
Analysis of Algorithms [ Section 4. 2. 5 ] Words of caution: • what is 10100 n ? • exponential algorithms are a big NO (unless the input is really small)