1 / 6

Algorithms

Algorithms. Randomized Algorithms Major Sources: Brassard and Bratley, Algorithmics: Theory and Practice Cormen, Lieserson, Rivest, and Stein, Introduction to Algorithms Horowitz, Sahni, and Rajasekaran, Computer Algorithms in C++. Randomized Algorithms.

Download Presentation

Algorithms

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Algorithms Randomized Algorithms Major Sources: Brassard and Bratley, Algorithmics: Theory and Practice Cormen, Lieserson, Rivest, and Stein, Introduction to Algorithms Horowitz, Sahni, and Rajasekaran, Computer Algorithms in C++

  2. Randomized Algorithms • Randomized algorithms make use of a randomizer (such as a random number generator). • Some of the decisions of the algorithm depend on the output of the randomizer. • The output may vary from run to run. • The execution time may vary from run to run.

  3. Major Classes of Randomized Algorithms • Las Vegas algorithms: • Always produce the same (correct) output for the same input • Execution time depends on the randomizer • Goal is often to minimize the odds of encountering worst case performance • Example: Randomized quick sort • Monte Carlo algorithms: • Occasionally gives an incorrect answer • The probability of an incorrect answer is required to be low. • Typically does not display variation in execution time for a particular input • Goal is to provide an answer that has a high likelihood of being correct in a reasonable time • Example: Determining primality of an integer with several hundred decimal digits.

  4. Analysis of Probabilistic Algorithms • Analysis is often complex and typically requires concepts from • Probability • Statistics • Number theory • Assume availability of Random(a,b) which returns an integer between a and b, inclusive with each integer being equally likely. • Assume cost of producing a single random value is constant • In practice we typically use pseudo-random number generators

  5. Randomly Permuting Arrays • Many randomized algorithms randomize the input by randomly permuting the elements of an array. • Two algorithms given in text • Permute by sorting (page 101) • Randomize in place (page 103)

  6. RANDOMIZE-IN-PLACE(A) • n  length[A] • for i  1 to n do • swap A[i]  A[RANDOM(i,n)] • How many permutations are there of n items? • For each permutation of n items, what is the probability that permutation will be produced by the above algorithm?

More Related