0% found this document useful (0 votes)
22 views

Module 4

This document discusses randomized algorithms. It explains that randomized algorithms make random choices during execution, so their behavior can vary each time even for the same input. The goal is to show that the algorithm is likely to perform well for every input. There are two main types of randomized algorithms: Las Vegas algorithms, which always produce the correct output but have random running times, and Monte Carlo algorithms, which may produce incorrect outputs with low probability. Examples of Las Vegas algorithms given include universal hashing, solving the n-queens problem, random sorting, and Dixon's integer factorization. The document also discusses strategies for Las Vegas algorithms and universal hashing in more detail.

Uploaded by

arunvinodh
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Module 4

This document discusses randomized algorithms. It explains that randomized algorithms make random choices during execution, so their behavior can vary each time even for the same input. The goal is to show that the algorithm is likely to perform well for every input. There are two main types of randomized algorithms: Las Vegas algorithms, which always produce the correct output but have random running times, and Monte Carlo algorithms, which may produce incorrect outputs with low probability. Examples of Las Vegas algorithms given include universal hashing, solving the n-queens problem, random sorting, and Dixon's integer factorization. The document also discusses strategies for Las Vegas algorithms and universal hashing in more detail.

Uploaded by

arunvinodh
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Module IV

Randomized Algorithms

Deterministic Algorithms

Goal: To prove that the algorithm solves the problem correctly always and quickly

typically the number of steps should be polynomial in the size of the input

Randomized Algorithms

In addition to input algorithm takes a source of random numbers and makes random choices during execution Behavior can vary even on a fixed input Goal: Design algorithm + analysis to show that this behavior is likely to be good on every input

Randomized Algorithms

Monte Carlo algorithms Las Vegas algorithms

Las Vegas algorithms

Always produces the same (correct) output for the same input Its running time is a random variable whose expectation is bounded say by a polynomial

Monte Carlo algorithms

Output might differ from run to run algorithm for the same input. Consider any problem for which there are only two possible answers, say yes or no If Monte carlo algorithm is used to solve such problem, the algorithm might give incorrect answers depending on the output of the randomizer Probability of incorrect answer should be LOW

Las Vegas algorithms


Universal Hashing N-queens problem Random Sorting Dixon's Integer Factorization algorithms

Basic Strategy of LV Algorithms

Las Vegas algorithm randomly makes decisions and then checks to see if they have resulted in a successful answer

Choosing A Hash Function


Choosing the hash function well is crucial
Bad hash function puts all elements in same slot A good hash function: Should distribute keys uniformly into slots Should not depend on patterns in the data

David Luebke

12/15/11

Universal Hashing
When attempting to foil an malicious adversary,

randomize the algorithm Universal hashing: pick a hash function randomly when the algorithm begins
Guarantees good performance on average, no matter what keys adversary chooses Need a family of hash functions to choose from

David Luebke

10

12/15/11

Universal Hashing
A family of hash functions

is said to be universal

if:
, the chance of a collision between x and y is exactly 1/m (x y) We can use this to get good expected performance: Choose h from a universal family of hash functions Hash n keys into a table of m slots, n m Then the expected number of collisions involving a particular key x is less than 1
With a random hash function from

David Luebke

11

12/15/11

The n queens problem


Many solutions to a classic problem: On an n x n chess board, place n queens so no queen threatens another

Minimal example 4 queens


4 x 4 Board Queen threatens next piece in any row, column or diagonal

Problem: Place 4 queens so no queen is threatened

What kind of problem?


Design state space for search nodes how to represent state edges what transformations to neighbouring state e.g., state: positions of four queens edge: move any queen to new position

www.animatedrecursion.com/advanced/the_eight_queens_problem.htm http://www.animatedrecursion.com/advanced/the_eight_queens_problem.html

Monte Carlo algorithms


Probablistic Counting Veryfying matrix multiplication Miller Rabin Test Pollard's rho heuristic

You might also like