12.07.2015 Views

A Practical Introduction to Data Structures and Algorithm Analysis

A Practical Introduction to Data Structures and Algorithm Analysis

A Practical Introduction to Data Structures and Algorithm Analysis

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

14<strong>Analysis</strong> TechniquesThis book contains many examples of asymp<strong>to</strong>tic analysis of the time requirementsfor algorithms <strong>and</strong> the space requirements for data structures. Often it is easy <strong>to</strong>invent an equation <strong>to</strong> model the behavior of the algorithm or data structure in question,<strong>and</strong> also easy <strong>to</strong> derive a closed-form solution for the equation should it containa recurrence or summation.Sometimes an analysis proves more difficult. It may take a clever insight <strong>to</strong> derivethe right model, such as the snowplow argument for analyzing the average runlength resulting from Replacement Selection (Section 8.5.2). In this case, once thesnowplow argument is unders<strong>to</strong>od, the resulting equations are simple. Sometimes,developing the model is straightforward but analyzing the resulting equations isnot. An example is the average-case analysis for Quicksort. The equation givenin Section 7.5 simply enumerates all possible cases for the pivot position, summingcorresponding costs for the recursive calls <strong>to</strong> Quicksort. However, deriving aclosed-form solution for the resulting recurrence relation is not as easy.Many iterative algorithms require that we compute a summation <strong>to</strong> determinethe cost of a loop. Techniques for finding closed-form solutions <strong>to</strong> summationsare presented in Section 14.1. Time requirements for many algorithms based onrecursion are best modeled by recurrence relations. A discussion of techniques forsolving recurrences is provided in Section 14.2. These sections extend the introduction<strong>to</strong> summations <strong>and</strong> recurrences provided in Section 2.4, so the reader shouldalready be familiar with that material.Section 14.3 provides an introduction <strong>to</strong> the <strong>to</strong>pic of amortized analysis. Amortizedanalysis deals with the cost of a series of operations. Perhaps a single operationin the series has high cost, but as a result the cost of the remaining operations islimited in such a way that the entire series can be done efficiently. Amortized analysishas been used successfully <strong>to</strong> analyze several of the algorithms presented in481

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!