Randomized Algorithms

28
Randomized Algorithms CS648 Lecture 20 Probabilistic Method (part 1) 1

Transcript of Randomized Algorithms

Randomized Algorithms CS648

Lecture 20

Probabilistic Method

(part 1)

1

Questions from Discrete Mathematics Question: (min-cuts)

How many min-cuts can there be in a graph on ๐’ vertices ?

Question: (Geometry)

There is a set ๐‘ท of ๐Ÿ๐ŸŽ๐ŸŽ points in plane and no three of them are collinear.

What can be the max. no. of acute triangles formed by these points ?

Question: (Number theory)

There is a set ๐‘จ of ๐’ positive integers. Aim is to compute a large subset ๐‘บ โŠ‚ ๐‘จ s.t.

there do not exist three elements ๐’Š, ๐’‹,๐’Œ โˆˆ ๐‘บ such that

๐’Š + ๐’‹ = ๐’Œ

How large can ๐‘บ be for any arbitrary ๐‘จ?

Theorem: (max-cut)

Every graph on ๐’ vertices and ๐’Ž edges has a cut of size โ‰ฅ โ€ฆ.. 2

๐’Ž/๐Ÿ

At least ๐’/๐Ÿ‘

At most ๐Ÿ•๐ŸŽ%

๐‘ถ(๐’๐Ÿ)

PROBABILISTIC METHODS

3

Probabilistic methods

Methods that use

โ€ข Probability theory

โ€ข Randomized algorithm

to prove deterministic combinatorial results

4

PROBLEM 1 HOW MANY MIN CUTS ?

5

Min-Cut

๐‘ฎ = (๐‘ฝ, ๐‘ฌ) : undirected connected graph

Definition (cut):

A subset ๐‘ช โŠ† ๐‘ฌ whose removal disconnects the graph.

Definition (min-cut): A cut of smallest size.

Question: How many cuts can there be in a graph?

Question: How many min-cuts can there be in a graph?

6

๐Ÿ๐’ โˆ’ ๐Ÿ

๐Ÿ

Algorithm for min-cut

Min-cut(๐‘ฎ):

{ Repeat ๐’ โˆ’ ๐Ÿ times

{

Let ๐’† โˆˆ๐’“ ๐‘ฎ;

๐‘ฎ Contract(๐‘ฎ, ๐’†).

}

return the edges of multi-graph ๐‘ฎ;

}

Running time: ๐‘ถ(๐’๐Ÿ)

Question: What is the sample space of the output of the algorithm ?

Answer: all-cuts of ๐‘ฎ.

7

Analysis of Algorithm for min-cut

Let ๐‘ช be any arbitrary min-cut.

Question: What is probability that ๐‘ช is preserved during the algorithm ?

Answer: 1 โˆ’๐Ÿ

๐’. 1 โˆ’

๐Ÿ

๐’โˆ’๐Ÿ. 1 โˆ’

๐Ÿ

๐’โˆ’๐Ÿโ€ฆ

3

5.2

4.1

3

= ๐’โˆ’๐Ÿ

๐’.

๐’โˆ’๐Ÿ‘

๐’โˆ’๐Ÿ.

๐’โˆ’๐Ÿ’

๐’โˆ’๐Ÿโ€ฆ

3

5.2

4.1

3

= ๐Ÿ

๐’.

๐Ÿ

๐’โˆ’๐Ÿ

8

Number of min-cuts

Let there be ๐’Œ min-cuts in ๐‘ฎ.

Let these min-cuts be ๐‘ช๐Ÿ, ๐‘ช๐Ÿ, โ€ฆ , ๐‘ช๐’Œ.

Define event โ„ฐ๐’Š : โ€œoutput of the algorithm Min-cut(๐‘ฎ) is ๐‘ช๐’Šโ€.

P(โ„ฐ๐’Š) โ‰ฅ ?

P(โˆช๐‘– โ„ฐ๐’Š) ? P(โ„ฐ๐Ÿ)+P(โ„ฐ๐Ÿ)+...P(โ„ฐ๐’Œ)

โ‰ฅ ๐’Œ๐Ÿ

๐’(๐’โˆ’๐Ÿ)

Surely P(โˆช๐‘– โ„ฐ๐’Š) โ‰ค 1

1 โ‰ฅ ๐’Œ๐Ÿ

๐’(๐’โˆ’๐Ÿ)

๐’Œ โ‰ค ๐’(๐’โˆ’๐Ÿ)

๐Ÿ

9

๐Ÿ

๐’(๐’ โˆ’ ๐Ÿ)

=

This is because at the end of the algorithm, we are left with a

multigraph with 2 vertices. This defines a cut uniquely.

Number of min-cuts

Let there be ๐’Œ min-cuts in ๐‘ฎ.

Let these min-cuts be ๐‘ช๐Ÿ, ๐‘ช๐Ÿ, โ€ฆ , ๐‘ช๐’Œ.

Define event โ„ฐ๐’Š : โ€œoutput of the algorithm Min-cut(๐‘ฎ) is ๐‘ช๐’Šโ€.

P(โ„ฐ๐’Š) โ‰ฅ ?

P(โˆช๐‘– โ„ฐ๐’Š) ? P(โ„ฐ๐Ÿ)+P(โ„ฐ๐Ÿ)+...P(โ„ฐ๐’Œ)

โ‰ฅ ๐’Œ๐Ÿ

๐’(๐’โˆ’๐Ÿ)

Surely P(โˆช๐‘– โ„ฐ๐’Š) โ‰ค 1

1 โ‰ฅ ๐’Œ๐Ÿ

๐’(๐’โˆ’๐Ÿ)

๐’Œ โ‰ค ๐’(๐’โˆ’๐Ÿ)

๐Ÿ

10

๐Ÿ

๐’(๐’ โˆ’ ๐Ÿ)

=

PROBLEM 2 HOW MANY ACUTE TRIANGLES ?

11

How many acute triangles

Problem Definition:

There is a set ๐‘ท of ๐Ÿ๐ŸŽ๐ŸŽ points in plane and no three of them are collinear.

How many triangles formed by these points are acute ?

Answer:

At most ๐Ÿ•๐ŸŽ%

Solution:

Let ๐’’ : probability that a triangle formed by 3 random points from ๐‘ท is acute.

๐’’ =Total number of acute triangles

All possible triangles using๐‘ท points

Show that ๐’’ โ‰ค ๐ŸŽ. ๐Ÿ•

12

๐Ÿ’ points

Case 1:

Sum of the four angles is ๐Ÿ‘๐Ÿ”๐ŸŽ.

at least one of them has to be โ‰ฅ 90

Hence, at least one of the four triangles is non-acute. 13

๐Ÿ’ points

Case 2:

Sum of the three angles at the center is ๐Ÿ‘๐Ÿ”๐ŸŽ.

at least two of these angles have to be > 90

at least 2 of the four triangles is non-acute. 14

๐Ÿ’ points ๐Ÿ“ points

Lemma1: A triangle formed by selecting 3 points randomly uniformly

from 4 points is acute triangle with probability at most ๐ŸŽ. ๐Ÿ•๐Ÿ“.

Lemma2: A triangle formed by selecting 3 points randomly uniformly

from 5 points is acute triangle with probability at most ๐ŸŽ. ๐Ÿ•.

(Do it as a simple exercise using Lemma 1.)

15

Extension to 100 points ?

Two stage sampling

๐‘ท: a set of ๐’ elements.

๐’‹ โ‰ค ๐’Œ โ‰ค ๐’

Let ๐‘บ be a uniformly random sample of ๐’Œ elements from ๐‘ท.

Let ๐‘น be a uniformly random sample of ๐’‹ elements from ๐‘บ.

Question: What can we say about (probability distribution of) ๐‘น ?

Answer: ๐‘น is a uniformly random sample of ๐’‹ elements from ๐‘ท.

(Do it as a simple exercise. It uses elementary probability)

Can you use this answer to calculate ๐’’ ?

16

Number of acute triangles

๐‘ท: set of ๐’ points.

๐’’ : probability that a triangle formed by 3 random points from ๐‘ท is acute.

๐’’ = ?

๐‘บ : a uniformly random sample of ๐Ÿ“ points from ๐‘ท.

๐‘น : a uniformly random sample of ๐Ÿ‘ points from ๐‘บ.

๐’’ = ?

๐’’ โ‰ค ๐ŸŽ. ๐Ÿ•๐ŸŽ

17

P(a random triangle from ๐‘บ is acute)

PROBLEM 3 LARGE CUT IN A GRAPH

18

Large cut in a graph

Problem Definition:

Let ๐‘ฎ be an undirected graph on ๐’ vertices and ๐’Ž edges.

We wish to split its vertices into two nonempty sets ๐‘จ and ๐‘จ

so that there are maximum number of edges in the cut(๐‘จ , ๐‘จ ).

What can be the maximum size cut we can get in this manner ?

Answer:

At least ๐’Ž/๐Ÿ

Spend some time to find out a proof for this bound.

Hopefully, after the problems we solved today,

you would have realized the way probabilistic method works.

19

Large cut in a graph

A randomized algorithm:

๐‘จโˆ…;

Add each vertex from ๐‘ฝ to ๐‘จ randomly independently with probability ๐Ÿ

๐Ÿ.

Return the cut defined by ๐‘จ.

20

Large cut in a graph

๐‘ฟ: size of cut (๐‘จ, ๐‘จ ) returned by the randomized algorithm.

E[๐‘ฟ] = ??

๐‘ฟ๐’†: ๐Ÿ if ๐’† is present in the cut๐ŸŽ otherwise

๐‘ฟ = ๐‘ฟ๐’†๐’†

E[๐‘ฟ] = ๐„[๐—๐’†]๐’†

= ๐(๐—๐’† = ๐Ÿ)๐’†

= ๐Ÿ

๐Ÿ๐’†

=๐’Ž

๐Ÿ

21

Large cut in a graph

Now use the following result which is simple but very useful.

Let ๐‘ฟ is a random variable defined over a probability space (๐›€, ๐).

If ๐„ ๐‘ฟ = ๐œถ, then there exists an elementary event ๐Ž โˆˆ ๐›€, such that ๐‘ฟ ๐Ž โ‰ฅ ๐œถ.

Use it to conclude that there is a cut of size at least ๐’Ž

๐Ÿ.

22

PROBLEM 4 SUM FREE SUBSET OF LARGE SIZE

23

Large subset that is sum-free

Problem Definition:

There is a set ๐‘จ of ๐’ positive integers.

Aim is to compute a large subset ๐‘บ โŠ‚ ๐‘จ such that

there do not exist three elements ๐’Š, ๐’‹,๐’Œ โˆˆ ๐‘บ such that

๐’Š + ๐’‹ = ๐’Œ

How large can ๐‘บ be for any arbitrary ๐‘จ?

Answer:

At least ๐’/๐Ÿ‘

24

Large subset that is sum-free

Let ๐’‘ > ๐’Ž๐’‚๐’™(๐‘จ) be a prime number.

Let ๐’‘ = ๐Ÿ‘๐’Œ + ๐Ÿ. //The other choice ๐Ÿ‘๐’Œ + ๐Ÿ is also fine here.

A randomized algorithm:

Select a random number ๐’’ from {1, ๐’‘ โˆ’ ๐Ÿ}.

Map each element ๐’• โˆˆ ๐‘จ to ๐’•๐’’ mod ๐’‘.

๐‘บ all those elements of ๐‘จ that get mapped to {๐’Œ + ๐Ÿ,โ€ฆ , ๐Ÿ๐’Œ + ๐Ÿ} ?

Return ๐‘บ;

Question: What is the expected number of elements from ๐‘จ that are mapped to {๐’Œ + ๐Ÿ,โ€ฆ , ๐Ÿ๐’Œ + ๐Ÿ} ?

Answer: > ๐’/๐Ÿ‘

25

To prove it, use โ€ข the fact that mapping is 1-1 and uniform. โ€ข and Linearity of expectation.

Large subset that is sum-free

Let ๐’‘ > ๐’Ž๐’‚๐’™(๐‘จ) be a prime number.

Let ๐’‘ = ๐Ÿ‘๐’Œ + ๐Ÿ.

A randomized algorithm:

Select a random number ๐’’ from {1, ๐’‘ โˆ’ ๐Ÿ}.

Map each element ๐’• โˆˆ ๐‘จ to ๐’•๐’’ mod ๐’‘.

๐‘บ all those elements of ๐‘จ that get mapped to {๐’Œ + ๐Ÿ,โ€ฆ , ๐Ÿ๐’Œ + ๐Ÿ} ?

Return ๐‘บ;

Claim: ๐‘บ is sum-free.

26

Showing that ๐‘บ is sum-free.

Let ๐’Š and ๐’‹ be any two elements in ๐‘บ.

Let ๐’Š gets mapped to ๐œถ and ๐’‹ gets mapped to ๐œท and ๐œถ, ๐œท โˆˆ [๐’Œ + ๐Ÿ, 2๐’Œ + ๐Ÿ]

Hence ๐œถ = ๐’Š๐’’ ๐ฆ๐จ๐ ๐’‘ and ๐œท = ๐’‹๐’’ ๐ฆ๐จ๐ ๐’‘

we just need to show that ๐’Š + ๐’‹ , if present in ๐‘จ, must not be mapped in [๐’Œ + ๐Ÿ, 2๐’Œ + ๐Ÿ].

๐’Š + ๐’‹ will be mapped to ??

Give suitable arguments to conclude that

โ€ข (๐œถ + ๐œท) must be greater than 2๐’Œ + ๐Ÿ.

โ€ข If (๐œถ + ๐œท) > ๐’‘, then (๐œถ + ๐œท) ๐ฆ๐จ๐ ๐’‘ would be strictly less than ๐’Œ.

27

1 2 โ€ฆ ๐’Œ ๐’Œ + ๐Ÿ โ€ฆ โ€ฆ โ€ฆ ๐Ÿ๐’Œ + ๐Ÿ โ€ฆ 3๐’Œ + ๐Ÿ ๐œถ ๐œท

(๐œถ + ๐œท) ๐ฆ๐จ๐ ๐’‘

โ€ข Try to ponder over the entire solution given for the Large sum-free subset problem.

โ€ข Try to realize the importance of each part of the solution (primality of ๐’‘, the choice of middle third, โ€ฆ)

โ€ข This solution is inspired by our discussion on โ€œhashing with constant search timeโ€.

โ€ข Can you see it ?

28