SlideShare a Scribd company logo
1 of 34
Randomized Algorithms
CS648
Lecture 3
• Two fundamental problems
• Balls into bins
• Randomized Quick Sort
• Random Variable and Expected value
1
BALLS INTO BINS
CALCULATING PROBABILITY OF SOME INTERESTING EVENTS
2
Balls into Bins
3
1 2 3 … i … n
1 2 3 4 5 … m-1 m
Balls into Bins
Question : What is the probability that there is at least one empty bin ?
4
1 2 3 … i … n
1 2 3 4 5 … m-1 m
Balls into Bins
5
1 2 3 … i … n
1 2 3 4 5 … m-1 m
Balls into Bins
6
1 2 3 … i … n
1 2 3 4 5 … j … m-1 m
disjoint
Independent
Independent
Balls into Bins
7
1 2 3 … i … n
1 2 3 4 5 … j … m-1 m
Balls into Bins
8
1 2 3 … i … n
1 2 3 4 5 … j … m-1 m
Balls into Bins
9
Express the event as union of some events …
Balls into Bins
10
Balls into Bins
11
RANDOMIZED QUICK SORT
WHAT IS PROBABILITY OF TWO SPECIFIC ELEMENTS GETTING COMPARED ?
12
Randomized Quick Sort
13
Randomized Quick Sort
14
Not a feasible way to calculate the probability
15
Go through the next few slides slowly and patiently,
pondering at each step. Never accept anything until
and unless you can see the underlying truth yourself.
16
Elements of A arranged in
Increasing order of values
17
18
19
ALTERNATE SOLUTION
USING ANALOGY TO ANOTHER RANDOM EXPERIMENT
Remember we took a similar approach earlier too:
we used a coin toss experiment to analyze failure probability of Rand-
Approx-Median algorithm.
20
A Random Experiment:
A Story of two friends
21
Viewing the entire experiment
from perspective of A and B
22
1 2 3 4 … n-1 n
A B
Viewing the entire experiment
from perspective of A and B
23
1 2 3 4 … n-1 n
A B
Viewing the entire experiment
from perspective of A and B
24
A B
Viewing the entire experiment
from perspective of A and B
25
A B
Viewing the entire experiment
from perspective of A and B
26
A B
Viewing the entire experiment
from perspective of A and B
27
A B
PROBABILITY THEORY
(RANDOM VARIABLE AND EXPECTED VALUE)
28
Random variable
29
Randomized-
Quick-Sort
on array of size
n
Number of HEADS
in 5 tosses
Sum of numbers
in 4 throws
Number of
comparisons
Random variable
30
Many Random Variables
for the same Probability space
Random Experiment: Throwing a dice two times
• X : the largest number seen
• Y : sum of the two numbers seen
31
Expected Value of a random variable
(average value)
32
Ω
X= a X= b
X= c
Examples
33
Can we solve these problems ?
34
Spend at least half an hour to solve these two problems using
the tools you know. This will help you appreciate the very
important concept we shall discuss in the next class.

More Related Content

Similar to Lecture 3-cs648 Randomized Algorithms

Lecture 3-cs648
Lecture 3-cs648Lecture 3-cs648
Lecture 3-cs648Rajiv Omar
 
Lecture 2-cs648 Randomized Algorithms
Lecture 2-cs648 Randomized AlgorithmsLecture 2-cs648 Randomized Algorithms
Lecture 2-cs648 Randomized AlgorithmsAnshul Yadav
 
Chapter 3 SE 2015.pptx
Chapter 3 SE 2015.pptxChapter 3 SE 2015.pptx
Chapter 3 SE 2015.pptxmiki304759
 
098A_exponents_factoring.ppt
098A_exponents_factoring.ppt098A_exponents_factoring.ppt
098A_exponents_factoring.pptMarjorie Malveda
 
098A_exponents_factoring.ppt
098A_exponents_factoring.ppt098A_exponents_factoring.ppt
098A_exponents_factoring.pptElmabethDelaCruz1
 
Lecture 2-cs648
Lecture 2-cs648Lecture 2-cs648
Lecture 2-cs648Rajiv Omar
 
A small debate of power of randomness
A small debate of power of randomnessA small debate of power of randomness
A small debate of power of randomnessAbner Chih Yi Huang
 
unit-3-permutation_combination.pptx
unit-3-permutation_combination.pptxunit-3-permutation_combination.pptx
unit-3-permutation_combination.pptxPradip738766
 
Lecture 4-cs648
Lecture 4-cs648Lecture 4-cs648
Lecture 4-cs648Rajiv Omar
 
Balls and-bins model app
Balls and-bins model appBalls and-bins model app
Balls and-bins model appdeawoo Kim
 
Lecture 9-cs648-2013
Lecture 9-cs648-2013Lecture 9-cs648-2013
Lecture 9-cs648-2013Rajiv Omar
 
1 - Probabilty Introduction .ppt
1 - Probabilty Introduction .ppt1 - Probabilty Introduction .ppt
1 - Probabilty Introduction .pptVivek Bhartiya
 
Lecture 2-cs648
Lecture 2-cs648Lecture 2-cs648
Lecture 2-cs648Rajiv Omar
 
Artificial Intelligence Alpha Beta pruning.pptx
Artificial Intelligence Alpha Beta pruning.pptxArtificial Intelligence Alpha Beta pruning.pptx
Artificial Intelligence Alpha Beta pruning.pptxKalpana Mohan
 

Similar to Lecture 3-cs648 Randomized Algorithms (20)

Lecture 3-cs648
Lecture 3-cs648Lecture 3-cs648
Lecture 3-cs648
 
Lecture 2-cs648 Randomized Algorithms
Lecture 2-cs648 Randomized AlgorithmsLecture 2-cs648 Randomized Algorithms
Lecture 2-cs648 Randomized Algorithms
 
Chapter 3 SE 2015.pptx
Chapter 3 SE 2015.pptxChapter 3 SE 2015.pptx
Chapter 3 SE 2015.pptx
 
098A_exponents_factoring.ppt
098A_exponents_factoring.ppt098A_exponents_factoring.ppt
098A_exponents_factoring.ppt
 
098A_exponents_factoring.ppt
098A_exponents_factoring.ppt098A_exponents_factoring.ppt
098A_exponents_factoring.ppt
 
Lecture 2-cs648
Lecture 2-cs648Lecture 2-cs648
Lecture 2-cs648
 
A small debate of power of randomness
A small debate of power of randomnessA small debate of power of randomness
A small debate of power of randomness
 
unit-3-permutation_combination.pptx
unit-3-permutation_combination.pptxunit-3-permutation_combination.pptx
unit-3-permutation_combination.pptx
 
Lecture 4-cs648
Lecture 4-cs648Lecture 4-cs648
Lecture 4-cs648
 
Balls and-bins model app
Balls and-bins model appBalls and-bins model app
Balls and-bins model app
 
Stat.pptx
Stat.pptxStat.pptx
Stat.pptx
 
jalalam.ppt
jalalam.pptjalalam.ppt
jalalam.ppt
 
Friedman's test
Friedman's testFriedman's test
Friedman's test
 
Probability
ProbabilityProbability
Probability
 
Lecture 9-cs648-2013
Lecture 9-cs648-2013Lecture 9-cs648-2013
Lecture 9-cs648-2013
 
1 - Probabilty Introduction .ppt
1 - Probabilty Introduction .ppt1 - Probabilty Introduction .ppt
1 - Probabilty Introduction .ppt
 
Probability Theory for Data Scientists
Probability Theory for Data ScientistsProbability Theory for Data Scientists
Probability Theory for Data Scientists
 
Lecture 2-cs648
Lecture 2-cs648Lecture 2-cs648
Lecture 2-cs648
 
Chapter7ppt.pdf
Chapter7ppt.pdfChapter7ppt.pdf
Chapter7ppt.pdf
 
Artificial Intelligence Alpha Beta pruning.pptx
Artificial Intelligence Alpha Beta pruning.pptxArtificial Intelligence Alpha Beta pruning.pptx
Artificial Intelligence Alpha Beta pruning.pptx
 

More from Anshul Yadav

Theoretical assign-2-hints
Theoretical assign-2-hintsTheoretical assign-2-hints
Theoretical assign-2-hintsAnshul Yadav
 
Lecture 12-cs648-2013 Randomized Algorithms
Lecture 12-cs648-2013 Randomized AlgorithmsLecture 12-cs648-2013 Randomized Algorithms
Lecture 12-cs648-2013 Randomized AlgorithmsAnshul Yadav
 
Lecture 10-cs648=2013 Randomized Algorithms
Lecture 10-cs648=2013 Randomized AlgorithmsLecture 10-cs648=2013 Randomized Algorithms
Lecture 10-cs648=2013 Randomized AlgorithmsAnshul Yadav
 
Lecture 9-cs648-2013 Randomized Algorithms
Lecture 9-cs648-2013 Randomized AlgorithmsLecture 9-cs648-2013 Randomized Algorithms
Lecture 9-cs648-2013 Randomized AlgorithmsAnshul Yadav
 
Lecture 6-cs648 Randomized Algorithms
Lecture 6-cs648 Randomized AlgorithmsLecture 6-cs648 Randomized Algorithms
Lecture 6-cs648 Randomized AlgorithmsAnshul Yadav
 
Lecture 7-cs648 Randomized Algorithms
Lecture 7-cs648 Randomized AlgorithmsLecture 7-cs648 Randomized Algorithms
Lecture 7-cs648 Randomized AlgorithmsAnshul Yadav
 

More from Anshul Yadav (9)

Lecture 19-cs648
Lecture 19-cs648Lecture 19-cs648
Lecture 19-cs648
 
Lecture 13-cs648
Lecture 13-cs648Lecture 13-cs648
Lecture 13-cs648
 
Theoretical assign-2-hints
Theoretical assign-2-hintsTheoretical assign-2-hints
Theoretical assign-2-hints
 
Lecture 12-cs648-2013 Randomized Algorithms
Lecture 12-cs648-2013 Randomized AlgorithmsLecture 12-cs648-2013 Randomized Algorithms
Lecture 12-cs648-2013 Randomized Algorithms
 
Lecture 10-cs648=2013 Randomized Algorithms
Lecture 10-cs648=2013 Randomized AlgorithmsLecture 10-cs648=2013 Randomized Algorithms
Lecture 10-cs648=2013 Randomized Algorithms
 
Lecture 9-cs648-2013 Randomized Algorithms
Lecture 9-cs648-2013 Randomized AlgorithmsLecture 9-cs648-2013 Randomized Algorithms
Lecture 9-cs648-2013 Randomized Algorithms
 
Lecture 6-cs648 Randomized Algorithms
Lecture 6-cs648 Randomized AlgorithmsLecture 6-cs648 Randomized Algorithms
Lecture 6-cs648 Randomized Algorithms
 
Lecture 7-cs648 Randomized Algorithms
Lecture 7-cs648 Randomized AlgorithmsLecture 7-cs648 Randomized Algorithms
Lecture 7-cs648 Randomized Algorithms
 
Lecture 1-cs648
Lecture 1-cs648Lecture 1-cs648
Lecture 1-cs648
 

Recently uploaded

Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Principled Technologies
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 

Recently uploaded (20)

Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Lecture 3-cs648 Randomized Algorithms