Book contents
- Frontmatter
- Contents
- Preface
- Introduction
- Part One Iterative Algorithms and Loop Invariants
- Part Two Recursion
- Part Three Optimization Problems
- 13 Definition of Optimization Problems
- 14 Graph Search Algorithms
- 15 Network Flows and Linear Programming
- 16 Greedy Algorithms
- 17 Recursive Backtracking
- 18 Dynamic Programming Algorithms
- 19 Examples of Dynamic Programs
- 20 Reductions and NP-Completeness
- 21 Randomized Algorithms
- Part Four Appendix
- Part five Exercise Solutions
- Index
21 - Randomized Algorithms
Published online by Cambridge University Press: 05 June 2012
- Frontmatter
- Contents
- Preface
- Introduction
- Part One Iterative Algorithms and Loop Invariants
- Part Two Recursion
- Part Three Optimization Problems
- 13 Definition of Optimization Problems
- 14 Graph Search Algorithms
- 15 Network Flows and Linear Programming
- 16 Greedy Algorithms
- 17 Recursive Backtracking
- 18 Dynamic Programming Algorithms
- 19 Examples of Dynamic Programs
- 20 Reductions and NP-Completeness
- 21 Randomized Algorithms
- Part Four Appendix
- Part five Exercise Solutions
- Index
Summary
For some computational problems, allowing the algorithm to flip coins (i.e., use a random number generator) makes for a simpler, faster, easier-to-analyze algorithm. The following are the three main reasons.
Hiding the Worst Cases from the Adversary: The running time of a randomized algorithms is analyzed in a different way than that of a deterministic algorithm. At times, this way is fairer and more in line with how the algorithm actually performs in practice. Suppose, for example, that a deterministic algorithm quickly gives the correct answer on most input instances, yet is very slow or gives the wrong answer on a few instances. Its running time and its correctness are generally measured to be those on these worst case instances. A randomized algorithm might also sometimes be very slow or give the wrong answer. (See the discussion of quick sort, Section 9.1). However, we accept this, as long as on every input instance, the probability of doing so (over the choice of random coins) is small.
Probabilistic Tools: The field of probabilistic analysis offers many useful techniques and lemmas that can make the analysis of the algorithm simple and elegant.
Solution Has a Random Structure: When the solution that we are attempting to construct has a random structure, a good way to construct it is to simply flip coins to decide how to build each part. Sometimes we are then able to prove that with high probability the solution obtained this way has better properties than any solution we know how to construct deterministically.
- Type
- Chapter
- Information
- How to Think About Algorithms , pp. 346 - 354Publisher: Cambridge University PressPrint publication year: 2008