Docsity

Growth Rates - Advanced Programming - Lecture Slides, Slides of Computer Science

Partial preview of the text

Download Growth Rates - Advanced Programming - Lecture Slides and more Slides Computer Science in PDF only on Docsity!

Analysis of Algorithms Growth Rates

Choosing n in t(n)

  • The analysis of algorithms attempts to optimize some criticalresource. The critical resource usually chosen is time, so t(n)
  • represents a time function. t(n) is influenced by hardware and compiler. Other factors
  • include the algorithm used and input to the algorithm.Parameter n , usually referring to number of data items

n processed, affects running time most significantly. may be degree of polynomial, size of file to be sorted or searched,

number of nodes in a graph, etc.

• • An algorithm may run faster on certain data sets than on others.Finding the average case can be very difficult, so typically algorithms areAverage Case and Worse Case

  • measured by the worst-case time complexity.Also, in certain application domains (e.g., air traffic control, surgery, IP lookup)knowing the worst-case time complexity is of crucial importance.

Input

1 ms2 ms

3 ms4 ms

5 ms A B C D E F G

worst-case

}best-caseaverage-case?

Functions in Increasing OrderComparison of Growth Rates Function log c N Name log N^2 N N log N 2 N N 2 N^3

Logarithmic^ Constant Log-squared Linear Quadratic^ N^ log^ N Exponential^ Cubic

Comparison of Growth Rates (cont)

0

500

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

f(n) = n f(n) = log(n) f(n) = n log(n)
f(n) = n^2 f(n) = n^3 f(n) = 2^n

Comparison of Growth Rates (cont)

0

1000

1 3 5 7 9 11 13 15 17 19

f(n) = n f(n) = log(n) f(n) = n log(n)
f(n) = n^2 f(n) = n^3 f(n) = 2^n

Comparison of Growth Rates (cont)