Low time complexity
Time complexity refers to the measure of the time efficiency of any given algorithm. We want to determine the execution time of our Java applications and ensure our algorithms do not add time complexity to our applications. The overall goal is to reduce algorithm execution time. We should test our algorithms using a variety of possible inputs and environments.
In this section, we will look at specific strategies to help you reduce the time complexity of your algorithms. We will also address the common pitfalls associated with time complexity.
Strategies for reducing time complexity
There are several strategies we can adopt to help us reduce the time complexity of our algorithms. Perhaps the easiest strategy is to simply ensure our algorithms are not overly complicated. This strategy requires us to double-check our algorithmic logic and use the optimization techniques covered throughout this book. Reducing unnecessary calculations within a loop, especially...