Xi%20=%20indicator%20random%20variable%20of%20the%20event%20that%20i-th%20person - PowerPoint PPT Presentation

About This Presentation
Title:

Xi%20=%20indicator%20random%20variable%20of%20the%20event%20that%20i-th%20person

Description:

e. permutations with 1 fixed point. number = derangement = permutation ... [e,i] Heap-Extract-Max (H); Pi Pi 1; Max-Heap-Insert( H, [Ai [Pi],i] ); add e to B ... – PowerPoint PPT presentation

Number of Views:28
Avg rating:3.0/5.0
Slides: 23
Provided by: csRoch
Category:

less

Transcript and Presenter's Notes

Title: Xi%20=%20indicator%20random%20variable%20of%20the%20event%20that%20i-th%20person


1
Xi indicator random variable of the event that
i-th person gets his hat back.

EXi1/20 XX1X20
EX EX1 EX20 1
2
derangement permutation with no fixed points
? n! / e ?
number
permutations with 1 fixed point
3
derangement permutation with no fixed points
? n! / e ?
number
permutations with 1 fixed point
n ? (n-1)! / e ?
n ? (n-1)! / e ?
? 0.3678 ? 0.368
n!
4
(No Transcript)
5
Claim Alice wins only on HHH game.
1/8 - Alice wins, gets 6 7/8 -
Alice loses, pays 1 gets -1
Alices expected payoff (1/8) 6 (7/8)
(-1) - 1/8
Bob has the advantage.
6
(No Transcript)
7
Heap
MIN-HEAP-INSERT O(log
k) HEAP-EXTRACT-MIN O(log k)
P1
Pk

8
We will find the array Ai whose first element e
is the smallest, output e to B, remove e from
Ai, and repeat. We will use a heap H as follows
we find e using Heap-Extract-Min procedure and
then add the next element from Ai to H using
Min-Heap-Insert procedure. We make n calls to
Min-Heap-Insert and n calls to Heap-Extract-Min.
Hence the running time is O(n.log k). To
simplify the exposition we add ? at the end of
each array.
for i from 1 to k do Pi ? 1
Max-Heap-Insert( H,Ai1,i ) for j from 1 to n
do e,i ? Heap-Extract-Max (H) Pi
? Pi 1 Max-Heap-Insert( H, Ai Pi,i
) add e to B
9
(No Transcript)
10
lt
11
  • LA?1,RA?n,LB?1,RB?nwhile LAltRA do
  • MA? ? (LA RA)/2 ?
  • MB? ? (LB RB)/2 ?
  • if AMAltBMB then
  • LA? MA 1, RB? MB - 1 else
  • RA? MA, LB? MB
  • output smaller of ALA,BLB

lt
12
Randomized algorithm for median
SELECT k-th element
for random x
1)
x
ltx
gtx
R
L
2) recurse on the appropriate part
13
Quick-sort
for random x
1)
PARTITION
x
ltx
gtx
R
L
2) recurse on both parts
14
Quick-sort
R-QUICK-SORT (A, l, r) x ? random element
of Al,r q ? PARTITION(A,x,l,r)
R-QUICK-SORT(A,l,q-1) R-QUICK-SORT(A,q1,r)
15
Quick-sort
R-QUICK-SORT (A, l, r) x ? random element
of Al,r q ? PARTITION(A,x,l,r)
R-QUICK-SORT(A,l,q-1) R-QUICK-SORT(A,q1,r)
How many times is R-QUICK-SORT called?
16
R-QUICK-SORT (A, l, r) x ? random element
of Al,r q ? PARTITION(A,x,l,r)
R-QUICK-SORT(A,l,q-1) R-QUICK-SORT(A,q1,r)
Quick-sort
Time spent in PARTITION?
17
R-QUICK-SORT (A, l, r) x ? random element
of Al,r q ? PARTITION(A,x,l,r)
R-QUICK-SORT(A,l,q-1) R-QUICK-SORT(A,q1,r)
Quick-sort
Time spent in PARTITION?
compare x with all elements in Al,r
we will count the number of comparisons
18
R-QUICK-SORT (A, l, r) x ? random element
of Al,r q ? PARTITION(A,x,l,r)
R-QUICK-SORT(A,l,q-1) R-QUICK-SORT(A,q1,r)
Quick-sort
Time spent in PARTITION?
Let the elements of A after sorting be b1 lt
b2 lt lt bn
Let Xi,j be the indicator random variable for
the event bi is compared to bj.
19
Quick-sort
Time spent in PARTITION?
Let the elements of A after sorting be b1 lt
b2 lt lt bn
Let Xi,j be the indicator random variable for
the event bi is compared to bj.
What is the probability that bi and bj
are compared in the first round ?
20
Quick-sort
Time spent in PARTITION?
Let the elements of A after sorting be b1 lt
b2 lt lt bn
Let Xi,j be the indicator random variable for
the event bi is compared to bj.
What is the probability that bi and bj
are compared in the first round ?
2/n (the pivot has to be bi or bj)
21
Quick-sort
Time spent in PARTITION?
What is the probability that bi and bj
are compared ?
2/(j-i1)
Let bk be the first pivot such that i?k? j. bi,
bj get compared ? ki or kj k is uniformly
random in i,,j
22
Quick-sort
Time spent in PARTITION?
What is the probability that bi and bj
are compared ?
X ? Xi,j
2/(j-i1)
1?iltj? n
EXi,j 2/(j-i1)
n
2
2
EX? ? ? n O(n ln n)
j-i1
k
k2
1?iltj? n
Write a Comment
User Comments (0)
About PowerShow.com