11.07.2015 Views

Data Structures and Algorithm Analysis - Computer Science at ...

Data Structures and Algorithm Analysis - Computer Science at ...

Data Structures and Algorithm Analysis - Computer Science at ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

14<strong>Analysis</strong> TechniquesOften it is easy to invent an equ<strong>at</strong>ion to model the behavior of an algorithm ord<strong>at</strong>a structure. Often it is easy to derive a closed-form solution for the equ<strong>at</strong>ionshould it contain a recurrence or summ<strong>at</strong>ion. But sometimes analysis proves moredifficult. It may take a clever insight to derive the right model, such as the snowplowargument for analyzing the average run length resulting from ReplacementSelection (Section 8.5.2). In this example, once the snowplow argument is understood,the resulting equ<strong>at</strong>ions follow n<strong>at</strong>urally. Sometimes, developing the modelis straightforward but analyzing the resulting equ<strong>at</strong>ions is not. An example is theaverage-case analysis for Quicksort. The equ<strong>at</strong>ion given in Section 7.5 simply enumer<strong>at</strong>esall possible cases for the pivot position, summing corresponding costs forthe recursive calls to Quicksort. However, deriving a closed-form solution for theresulting recurrence rel<strong>at</strong>ion is not as easy.Many analyses of iter<strong>at</strong>ive algorithms use a summ<strong>at</strong>ion to model the cost of aloop. Techniques for finding closed-form solutions to summ<strong>at</strong>ions are presented inSection 14.1. The cost for many algorithms based on recursion are best modeledby recurrence rel<strong>at</strong>ions. A discussion of techniques for solving recurrences is providedin Section 14.2. These sections build on the introduction to summ<strong>at</strong>ions <strong>and</strong>recurrences provided in Section 2.4, so the reader should already be familiar withth<strong>at</strong> m<strong>at</strong>erial.Section 14.3 provides an introduction to the topic of amortized analysis. Amortizedanalysis deals with the cost of a series of oper<strong>at</strong>ions. Perhaps a singleoper<strong>at</strong>ion in the series has high cost, but as a result the cost of the remaining oper<strong>at</strong>ionsis limited. Amortized analysis has been used successfully to analyze severalof the algorithms presented in previous sections, including the cost of a series ofUNION/FIND oper<strong>at</strong>ions (Section 6.2), the cost of partition in Quicksort (Section7.5), the cost of a series of splay tree oper<strong>at</strong>ions (Section 13.2), <strong>and</strong> the cost ofa series of oper<strong>at</strong>ions on self-organizing lists (Section 9.2). Section 14.3 discussesthe topic in more detail.461

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

Saved successfully!

Ooh no, something went wrong!