Lecture 7-cs648

Preview:

Citation preview

Click to edit Master subtitle style

Randomized AlgorithmsCS648

Lecture 7Two applications of Union Theorem• Balls into Bin experiment : Maximum load• Randomized Quick Sort: Concentration of the running

time 1

Union theorem

2

Union theorem

3

Application 1 of the Union Theorem

balls into Bins: Maximum load

4

Balls into Bins

5

1 2 3 … i … n

1 2 3 4 5 … m-1 m

Balls into Bins

6

1 2 3 … j … n

1 2 3 4 5 … m-1 m

Balls into BinsThe main difficulty and the way out

7

1 2 3 … j … n

1 2 3 4 5 … m-1 m

8

1 2 3 … j … n

1 2 3 4 5 … m-1 m

9

1 2 3 … j … n

1 2 3 4 5 … m-1 m

10

11

Balls into Bins

12

Application 2 of the Union Theorem

Randomized Quick sort: The secret of its popularity

13

Concentration of Randomized Quick Sort

14

A

Concentration of Randomized Quick SortTools needed

15

Randomized QuickSort The main difficulty and the way out

16

Elements of A arranged in Increasing order of values

Randomized QuickSort The main difficulty and the way out

17

Elements of A arranged in Increasing order of values

18

Elements of A arranged in Increasing order of values

19

Randomized QuickSort A new way to count the comparisons

20

Elements of A arranged in Increasing order of values

Randomized QuickSort Applying Union theorem

21

22

Randomized Quick Sort

Definition: a recursive call is good if the pivot is selected from the middle half, and bad otherwise.

P(a recursive call is good) = ??

Notation: The size of a recursive call is the size of the subarray it sorts.23

middle-half

Increasing order of values

Randomized Quick Sort

24

middle-half

Increasing order of values

Randomized Quick Sort

25

middle-half

Increasing order of values

26

Randomized Quick SortFinal result

27

Some Well Known and Well STUDIEDRandom Variables

28

Bernoulli Random Variable

29

Binomial Random Variable

30

Geometric Random Variable

31

Negative Binomial Random Variable

32