DOC PREVIEW
UMD CMSC 351 - Randomized Algorithms

This preview shows page 1-2-3 out of 8 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

What does it mean for a value to be randomly selected?How can we make use of randomness?Monte Carlo Algorithms• Don’t always give the correct answer.• The runtime can be described consistently.Las Vegas Algorithms• They always give the correct answers.• Their runtime is not consistent.Algorithm• Select a value at random, call it p.• Partition the list around p.• See if it was the median (same number in each side of the partitioning).• If it is, great. If it wasn’t, oh well, try again…Question #1: Does this work?Question #2: Is it a good algorithm?Algorithm• Select a value at random, call it p.• Partition around p.• See if it was the median (same number in each side of the partitioning).• If it wasn’t, then we have still found the xth smallest value in the list (the value of x will be based on the size of the partitions).• If x is “before” the median, take the right side and find the (n/2-x)th smallest.• Otherwise, take the “left” side and find the (n/2)th smallest.Note: If this ends up being a good idea, we’d end up coding general selection.Question #1: Does this work?Question #2: Is it a good algorithm?How do we analyze the runtime of something like this?Partitioning takes n-1 comparisons.Random number generation may take some time (we'll ignore this for now).The recursion may or may not be needed, and we don’t know exactly how many values will be passed into that recursion.T(n) = n + T(???)The best case is easy, we find it on the first shot and it’s n-1 comparisons.What about worst case and average case?We will assume unique values in the list.We’ll round things and say the partitioning takes n comparisons.We will look at “worst” expected runtime.We’ll compute assuming we have to look in the larger of the two sub-lists (which is true for median finding).We won’t worry about floor/ceiling issues in this initial


View Full Document
Download Randomized Algorithms
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Randomized Algorithms and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Randomized Algorithms 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?