So far, we've understood why analyzing the complexity of an algorithm is really important. Now it's time to understand how to analyze the complexity. Before moving ahead with the how-to part, let's understand that, once the complexity of an algorithm is analyzed, there should be some way to represent it. For that, we usually use different notations.
As mentioned earlier, an algorithm can behave differently based on the size of the input given to it. And in the computer world, if you're building software, your algorithm should be prepared for any size of input. So, it's obvious that we need to analyze the complexity of every possible case.
The complexity of an algorithm can broadly fall into the following three categories:
- Best case analysis: Best case defines the minimum time required by an algorithm to produce the output. It...