Skip to article frontmatterSkip to article content

Chapter 3: Characterizing Running Times

The order of growth of the running time of an algorithm, defined in Chapter 2: Getting Started, gives a simple way to characterize the algorithm’s efficiency and also allows us to compare it with alternative algorithms. Once the input size nn becomes large enough, merge sort, with its Θ(nlgn)\Theta(n \lg n) worst-case running time, beats insertion sort, whose worst-case running time is Θ(n2)\Theta(n^2). Although we can sometimes determine the exact running time of an algorithm, as we did for insertion sort in Chapter 2, the extra precision is rarely worth the effort of computing it. For large enough inputs, the multiplicative constants and lower-order terms of an exact running time are dominated by the effects of the input size itself.

When we look at input sizes large enough to make relevant only the order of growth of the running time, we are studying the asymptotic efficiency of algorithms. That is, we are concerned with how the running time of an algorithm increases with the size of the input in the limit, as the size of the input increases without bound. Usually, an algorithm that is asymptotically more efficient is the best choice for all but very small inputs.

This chapter gives several standard methods for simplifying the asymptotic analysis of algorithms. The next section presents informally the three most commonly used types of “asymptotic notation,” of which we have already seen an example in Θ\Theta-notation. It also shows one way to use these asymptotic notations to reason about the worst-case running time of insertion sort. Then we look at asymptotic notations more formally and present several notational conventions used throughout this book. The last section reviews the behavior of functions that commonly arise when analyzing algorithms.

SectionTitle
3.13.1 O-notation, Ω-notation, and Θ-notation
3.23.2 Asymptotic notation: formal definitions
3.33.3 Standard notations and common functions
3.4Problems
3.5Chapter Notes