SlideShare a Scribd company logo
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

PPTX
Parabola lab day 3
PPTX
Lecture 5-cs648 Randomized Algorithms
PPTX
Lecture 18-cs648
PPTX
Lecture 17-cs648
PPTX
Lecture 4-cs648 Randomized Algorithms
PPTX
Lecture 11-cs648-2013 Randomized Algorithms
PPTX
Lecture 14-cs648-2013
PPTX
Lecture 16
Parabola lab day 3
Lecture 5-cs648 Randomized Algorithms
Lecture 18-cs648
Lecture 17-cs648
Lecture 4-cs648 Randomized Algorithms
Lecture 11-cs648-2013 Randomized Algorithms
Lecture 14-cs648-2013
Lecture 16

Similar to Lecture 3-cs648 Randomized Algorithms (20)

PPTX
Lecture 3-cs648
PPTX
Lecture 4-cs648
PPTX
Lecture 2-cs648 Randomized Algorithms
PPT
Discrete probability
PPTX
Lecture 2-cs648
ODP
Lecture 2-cs648
PDF
Probability_and_Statistics_for_engieers_
PPT
Probability And Random Variable Lecture 1
PDF
Probability
PDF
Bai giang Chapter 6 avandce math for engeneering
PPTX
Presentation1.pptx... Learn and understand everything
PPT
Cis435 week03
PPT
prob Probability PowerPoint notes Probability PowerPoint notes
PDF
STAB52 Introduction to probability (Summer 2025) Lecture 1
PPT
Chapter07
PPTX
CHAPTER I- Part 1.pptx
PPTX
Cs221 probability theory
PPTX
Probability Theory for Data Scientists
PDF
schaum_probability.pdf
PDF
Random variables
Lecture 3-cs648
Lecture 4-cs648
Lecture 2-cs648 Randomized Algorithms
Discrete probability
Lecture 2-cs648
Lecture 2-cs648
Probability_and_Statistics_for_engieers_
Probability And Random Variable Lecture 1
Probability
Bai giang Chapter 6 avandce math for engeneering
Presentation1.pptx... Learn and understand everything
Cis435 week03
prob Probability PowerPoint notes Probability PowerPoint notes
STAB52 Introduction to probability (Summer 2025) Lecture 1
Chapter07
CHAPTER I- Part 1.pptx
Cs221 probability theory
Probability Theory for Data Scientists
schaum_probability.pdf
Random variables
Ad

More from Anshul Yadav (9)

PPTX
Lecture 19-cs648
PPTX
Lecture 13-cs648
PPTX
Theoretical assign-2-hints
PPTX
Lecture 12-cs648-2013 Randomized Algorithms
PPTX
Lecture 10-cs648=2013 Randomized Algorithms
PPTX
Lecture 9-cs648-2013 Randomized Algorithms
PPTX
Lecture 6-cs648 Randomized Algorithms
PPTX
Lecture 7-cs648 Randomized Algorithms
PPTX
Lecture 1-cs648
Lecture 19-cs648
Lecture 13-cs648
Theoretical assign-2-hints
Lecture 12-cs648-2013 Randomized Algorithms
Lecture 10-cs648=2013 Randomized Algorithms
Lecture 9-cs648-2013 Randomized Algorithms
Lecture 6-cs648 Randomized Algorithms
Lecture 7-cs648 Randomized Algorithms
Lecture 1-cs648
Ad

Recently uploaded (20)

PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
Spectroscopy.pptx food analysis technology
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Electronic commerce courselecture one. Pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Encapsulation theory and applications.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
KodekX | Application Modernization Development
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Spectroscopy.pptx food analysis technology
Advanced methodologies resolving dimensionality complications for autism neur...
sap open course for s4hana steps from ECC to s4
Dropbox Q2 2025 Financial Results & Investor Presentation
Electronic commerce courselecture one. Pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Digital-Transformation-Roadmap-for-Companies.pptx
Spectral efficient network and resource selection model in 5G networks
Encapsulation theory and applications.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Approach and Philosophy of On baking technology
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
KodekX | Application Modernization Development
Diabetes mellitus diagnosis method based random forest with bat algorithm
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Mobile App Security Testing_ A Comprehensive Guide.pdf
20250228 LYD VKU AI Blended-Learning.pptx

Lecture 3-cs648 Randomized Algorithms