How can we modify almost any algorithm to have a good best-case running time?

We can design any algorithm to treat its best-case scenario as a special case and return a predetermined solution.

For example, for selection sort, we can check whether the input array is already sorted and if it is, we will not do anything. So, selection sort will run with a best-case running time of .

If you have any question or suggestion or you have found any error in this solution, please leave a comment below.