Module 4
Module 4
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
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
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
Universal Hashing N-queens problem Random Sorting Dixon's Integer Factorization algorithms
Las Vegas algorithm randomly makes decisions and then checks to see if they have resulted in a successful answer
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
www.animatedrecursion.com/advanced/the_eight_queens_problem.htm http://www.animatedrecursion.com/advanced/the_eight_queens_problem.html
Probablistic Counting Veryfying matrix multiplication Miller Rabin Test Pollard's rho heuristic