The case complexity of an algorithm refers to the expected amount of time it takes to execute for inputs of typical size.
Worst-case time complexity
When analyzing the complexity of an algorithm, we often use the notation , which represents an upper bound on the growth rate of the algorithm's time or space requirements.
The best case complexity of an algorithm refers to the amount of time or space it can take to execute.
O(1)
O(n)
The worst case complexity of an algorithm refers to the amount of time it can take to execute.
notation provides a way to express the upper bound of an algorithm's time or space complexity in a simple and concise manner.
The case complexity gives us an idea of how the algorithm performs on inputs that are representative of real-world scenarios.
Best-case time complexity
Which of the following is the best time complexity?
The case complexity is important because it guarantees that the algorithm will not perform worse than a certain threshold.
In the context of complexity analysis, the term case refers to the scenario in which the algorithm performs exceptionally well.