Randomized “Algorithms”

1 / 6

# Randomized “Algorithms” - PowerPoint PPT Presentation

Randomized “Algorithms”. Monte Carlo and Las Vegas Technuques. Randomized. Monte Carlo Might give an incorrect answer (approximate) but always give an answer Las Vegas Might never give an answer (quit or run forever) Each uses some randomized technique to attack a problem.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## Randomized “Algorithms”

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
1. Randomized “Algorithms” Monte Carlo and Las Vegas Technuques

2. Randomized • Monte Carlo • Might give an incorrect answer (approximate) but always give an answer • Las Vegas • Might never give an answer (quit or run forever) • Each uses some randomized technique to attack a problem

3. Monte Carlo Integration float area(function f, float a, float b, float fMax, int n) { float x, y; int hits=0, trial; for (trial=0; trial<n; trial++) { x = a+random(b-a); y = random(fMax); if (f(x)>=y) hits++; } return((b-a)*fMax*hits/n); }

4. Las Vegas and Ethernet bool success = false; while (!success) { status = message.send(); success = status == TRANSMITTED; if (!success) wait a bit; }

5. Las Vegas Dining Philosophers • Discussed in class Monte Carlo Illumination • Discussed in class

6. References • Some material from the textbook: Data Structures and Algorithm Analysis in Java (Second Edition) by Mark Allen Weiss • Additional images: www.wikipedia.com