What Is Rate of Growth?: Structures-And-Algorithms
What Is Rate of Growth?: Structures-And-Algorithms
Above is the list of growth rates you will come across in the following articles.
Types of Analysis:
To analyze the given algorithm, we need to know with which inputs the
algorithm takes less time (performing well) and with which inputs the algorithm takes a long time.
We have already seen that an algorithm can be represented in the form of an expression in growth
rate. That means we represent the algorithm with multiple expressions: one for the case where it
takes less time and another for the case where it takes more time.
In general, the first case is called the best case and the second case is called the worst case for the
algorithm. To analyze an algorithm we need some kind of syntax, and that forms the base for
asymptotic analysis/notation. There are three types of analysis:
• Worst case
○ Defines the input for which the algorithm takes a long time (slowest time to
complete).
○ Input is the one for which the algorithm runs the slowest.
• Best case
○ Defines the input for which the algorithm takes the least time (fastest time to
complete).
○ Input is the one for which the algorithm runs the fastest.
• Average case
○ Run the algorithm many times, using many different inputs that come from some
distribution that generates these inputs, compute the total running time (by adding the individual
times), and divide by the number of trials.
For a given algorithm, we can represent the best, worst and average cases in the
form of expressions. As an example, let f(n) be the function which represents the given algorithm.
Similarly for the average case.
The expression defines the inputs with which the algorithm takes the average running time (or
memory).