算法绪论 advalgo4

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

Proper 2-coloring
Let
∈ N and a set S . Moreover, S1 , . . . , Sm ⊆ S
with |Si | =
for all i ∈ [m].
Question
Can we color the elements of S by 2 colors such that none of Si ’s is monochromatic?
Theorem
If m < 2
−1
, then there exists a proper 2-coloring defined as above.
Proof
We color each element in S by white and black independently and uniformly at random. Then for each i ∈ [m] Pr Si is monochromatic = Now the union bound implies Pr there exists an i ∈ [m] such that Si is monochromatic ≤ That is Pr Si is not monochromatic for all i ∈ [m] > 0. m 2
mod p ) ∈ C =
|C | 1 > . |Z∗ | 3 p
Hence E |Ax | =
b ∈B x E[σb ]>
|B | . 3
The last two claims conclude the proof.
The Lov´ asz Local Lemma
The general setup
Let A1 , . . . , An be a set of bad events. Our goal is to establish Pr
Theorem (Bodlaender, 1990)
Let k ∈ N. Then there is a polynomial time algorithm which decides GI on graphs G with tw(G ) ≤ k .
RandomizΒιβλιοθήκη Baidud Algorithms
Median
x σb
=
1 0
if (x · b
mod p ) ∈ C , i.e., b ∈ Ax
otherwise.
Clearly |Ax | =
b ∈B
x σb , and thus
E |Ax | =
b ∈B
x E[σb ]
by the linearity of the expectation.
Proof (5)
∗ Let b ∈ B and y ∈ Z∗ p be fixed. Then there is a unique x ∈ Zp with
(x · b i.e., x = y · b −1 mod p . Thus
mod p ) = y ,
x x E[σb ] = Pr∗ σb = 1 = Pr∗ (x · b x ∈Zp x ∈Zp
Advanced Algorithms (IV)
Yijia Chen Fudan University
Review
Theorem
There is a polynomial time algorithm which computes a maximum matching in any given bipartite graph.
How to choose v ? (cont’d)
Worst-case scenario would force our selection algorithm to perform n + (n − 1) + (n − 2) + · · · + 1 = Θ(n2 ) Best-case scenario: O (n). Where, in this spectrum from O (n) to Θ(n2 ), does the average running time lie? Fortunately, it lies very close to the best-case time.
Therefore, (x · b1 mod p ), (x · b2 mod p ), and (x · b3 mod p ) would witness that C is not sum-free in Z∗ p.
Proof (4)
Claim
There exists an x ∈ Z∗ p such that |Ax | > |B |/3. We prove that if x ∈ Z∗ p is chosen uniformly at random, then E |Ax | > |B |/3. For every b ∈ B let
Lemma
On average a fair coin needs to be tossed two times before a “heads” is seen.
Proof.
E := expected number of tosses before head is seen. We need at least one toss, and it’s heads, we’re done. If it’s tail (with probability 1/2), we need to repeat. Hence E =1+ whose solution is E = 2 1 E, 2
For any number v , imagine splitting list S into three categories: elements smaller than v , i.e., SL ; those equal to v , i.e., Sv (there might be duplicates); and those greater than v , i.e., SR respectively. selection(SL , k ) selection(S , k ) = v selection(SR , k − |SL | − |Sv |)
The efficiency analysis (cont’d)
Let T (n) be the expected running time on an array of size n, we get T (n) ≤ T (3n/4) + O (n) = O (n).
Probabilistic methods
The probabilistic method was invented by Paul Erd˝ os. To prove an object with certain properties exits, we argue that an random object satisfies the desired properties with non-zero probability.
if k ≤ |SL | if |SL | < k ≤ |SL | + |Sv | if k > |SL | + |Sv |.
How to choose v ?
It should be picked quickly, and it should shrink the array substantially, the ideal situation being |S | |SL |, |SR | ≈ . 2 If we could always guarantee this situation, we would get a running time of T (n) = T (n/2) + O (n) = O (n). But this requires picking v to be the median, which is our ultimate goal! Instead, we follow a much simpler alternative: we pick v randomly from S .
−1
1 1 1 + = −1 . 2 2 2
< 1.
Sum-free sets
Definition
Let A ⊆ N. Then A is sum-free, if there do not exist a1 , a2 , a3 ∈ A with a1 + a2 = a3 .
Theorem (Erd˝ os, 1965)
Let B ⊆ N. Then there exists a sum-free A ⊆ B with |A | > |B | . 3
A tool: Z∗ p
Z∗ p is the multiplicative group on the elements 1, . . . , p − 1 , such that a · b := a × b mod p .
The efficiency analysis
v is good if it lies within the 25th to 75th percentile of the array that it is chosen from. A randomly chosen v has a 50% chance of being good,
Proof (3)
For every x ∈ Z∗ p and we define Ax := b ∈ B (x · b mod p ) ∈ C .
Claim
Ax is sum-free in N. Assume for some b1 , b2 , b3 ∈ Ax we have b1 + b2 = b3 . Then x · b1 + x · b2 ≡ x · b3 mod p .
Proof (2)
Claim
C is sum-free in Z∗ p. Assume k + i , k + j ∈ C , i.e., 1 ≤ i ≤ j ≤ k + 1. Then (k + i ) + (k + j ) mod p (= 3 · k + 2). is either in [2 · k + 2, 3 · k + 1] or in [0, k ], neither contained in C .
Selection
Input: A list S of numbers and an integer k . Output : The k th smallest element of S .
A randomized divide-and-conquer algorithm for selection
Proof (1)
Let b := max B and p be a prime with p >2·b Then we set C := k + 1, k + 2, . . . , 2k + 1 . Clearly C ⊆ Z∗ p and |C | k +1 1 > . = |Z∗ 3 · k + 1 3 | p and p = 3 · k + 2 for some k ∈ N.
Median
The median of a list of numbers is its 50th percentile: half the numbers are bigger than it, and half are smaller. If the list has even length, there are two choices for what the middle element could be, in which case we pick the smaller of the two, say. We can compute the median of n numbers by sorting which takes time O (n log n). Is that possible to do it in linear time?
相关文档
最新文档