Exercise 2.2-4

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

An approach that would work for any algorithm would be to include a ‘truth-check’ that rapidly verifies whether or not the input already satisfies the requirements of the desired output. For a sorting algorithm, we would look at the input array and determine if it is already sorted. This would result in a very fast best-case scenario, but sort of defeats the purpose of the underlying algorithm at the same time.