0
Upcoming SlideShare
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Standard text messaging rates apply

# Lecture 2-cs648

73

Published on

Published in: Technology, Education
0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total Views
73
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
0
0
Likes
0
Embeds 0
No embeds

No notes for slide

### Transcript

• 1. Randomized Algorithms CS648 Lecture 2 &#x2022; Randomized Algorithm for Approximate Median &#x2022; Elementary Probability theory 1
• 2. RANDOMIZED MONTE CARLO ALGORITHM FOR APPROXIMATE MEDIAN This lecture was delivered at slow pace and its flavor was that of a tutorial. Reason: To show that designing and analyzing a randomized algorithm demands right insight and just elementary probability. 2
• 3. A simple probability exercise 3
• 4. 4
• 5. Approximate median Definition: Given an array A[] storing n numbers and &#x3F5; &gt; 0, compute an element whose rank is in the range [(1- &#x3F5;)n/2, (1+ &#x3F5;)n/2]. Best Deterministic Algorithm: &#x2022; &#x201C;Median of Medians&#x201D; algorithm for finding exact median &#x2022; Running time: O(n) &#x2022; No faster algorithm possible for approximate median Can you give a short proof ? 5
• 6. &#xBD; - Approximate median A Randomized Algorithm Rand-Approx-Median(A) 1. Let k &#xF0DF; c log n; 2. S &#xF0DF; &#x2205;; 3. For i=1 to k 4. x &#xF0DF; an element selected randomly uniformly from A; 5. S &#xF0DF; S U {x}; 6. Sort S. 7. Report the median of S. Running time: O(log n loglog n) 6
• 7. Analyzing the error probability of Rand-approx-median n/4 Left Quarter Elements of A arranged in Increasing order of values 3n/4 Right Quarter When does the algorithm err ? To answer this question, try to characterize what will be a bad sample S ? 7
• 8. Analyzing the error probability of Rand-approx-median n/4 Elements of A arranged in Increasing order of values Left Quarter 3n/4 Median of S Right Quarter Observation: Algorithm makes an error only if k/2 or more elements sampled from the Right Quarter (or Left Quarter). 8
• 9. Analyzing the error probability of Rand-approx-median n/4 Elements of A arranged in Increasing order of values 3n/4 Right Quarter Left Quarter &#xBC; Exactly the same as the coin tossing exercise we did ! 9
• 10. Main result we discussed 10
• 11. ELEMENTARY PROBABILITY THEORY (IT IS SO SIMPLE THAT YOU UNDERESTIMATE ITS ELEGANCE AND POWER) 11
• 12. Elementary probability theory (Relevant for CS648) &#x2022; We shall mainly deal with discrete probability theory in this course. &#x2022; We shall take the set theoretic approach to explain probability theory. Consider any random experiment : o Tossing a coin 5 times. o Throwing a dice 2 times. o Selecting a number randomly uniformly from [1..n]. How to capture the following facts in the theory of probability ? 1. Outcome will always be from a specified set. 2. Likelihood of each possible outcome is non-negative. 3. We may be interested in a collection of outcomes. 12
• 13. Probability Space &#x3A9; 13
• 14. Event in a Probability Space A &#x3A9; 14
• 15. Exercises A randomized algorithm can also be viewed as a random experiment. 1. What is the sample space associated with Randomized Quick sort ? 2. What is the sample space associated with Rand-approx-median algorithm ? 15
• 16. An Important Advice In the following slides, we shall state well known equations (highlighted in yellow boxes) from probability theory. &#x2022; You should internalize them fully. &#x2022; We shall use them crucially in this course. &#x2022; Make sincere attempts to solve exercises that follow. 16
• 17. Union of two Events A B &#x3A9; 17
• 18. Union of three Events A B C &#x3A9; 18
• 19. Exercises 19
• 20. Conditional Probability 20
• 21. Exercises &#x2022; A man possesses five coins, two of which are double-headed, one is double-tailed, and two are normal. He shuts his eyes, picks a coin at random, and tosses it. What is the probability that the lower face of the coin is a head ? He opens his eyes and sees that the coin is showing heads; what it the probability that the lower face is a head ? He shuts his eyes again, and tosses the coin again. What is the probability that the lower face is a head ? He opens his eyes and sees that the coin is showing heads; what is the probability that the lower face is a head ? He discards this coin, picks another at random, and tosses it. What is the probability that it shows heads ? 21
• 22. Partition of sample space and an &#x201C;important Equation&#x201D; B &#x3A9; 22
• 23. Exercises 23
• 24. Independent Events P(A &#x2229; B) = P(A) &#xB7; P(B) 24
• 25. Exercises 25