Asymptotic Notations
This week, we learned about asymptotic notation and its use when analyzing recursive and nonrecursive algorithms. Last week, we learned about identifying the basic operation of an algorithm, which is the operation that contributes the most to the total running time. After all operations of an algorithm are analyzed and a basic operation is found, we can assign a function to the algorithm that represents the time efficiency of the algorithm. There are 8 common time efficiencies that are used. These can be found below and are in order from fastest (top) to slowest (bottom):
Once a function is assigned, we can use one of three asymptotic bounds and notations to display the order of growth of an algorithm. The three types of notation that can be used when analyzing an algorithm:
- Big 'O' (oh)
- Big 'Θ' (theta)
- Big 'Ω' (omega)
Big 'O' Notation
Big 'O' is used as an upper asymptotic bound and is written as O(f(n)). This means that all functions of the same order of growth or lower (will not grow faster) can be used to describe the algorithm using this notation. Below are some examples of functions that can be used when using O(n^2) for time efficiency. Each of the functions below is at a degree of n^2 or lower.
Big 'Θ' Notation
Big 'Θ' is used as an exact asymptotic bound and is written as Θ(f(n)). This means that all functions of the same order of growth can be used; no functions higher or lower can be used (will not grow faster or slower). Below are some examples of functions that can not be used when using Θ(n^2) for time efficiency. Each of the functions below does not have the same degree as n^2 and cannot be used with Θ(n^2).
Big 'Ω' is used as a lower asymptotic bound and is written as Ω(f(n)). This means that all functions of the same order of growth or higher (will not grow at least as fast) can be used for time efficiency. Below are some examples of functions that can be used when using Ω(n^2) for time efficiency. The last example shows an example of a function that we cannot use since it does not have a degree that this the same or higher than n^2.
Comments
Post a Comment