CSE 525: Randomized Algorithms Spring 2026 Lecture 2: Second Moment Method Lecturer: Shayan Oveis Gharan 04/02/2026 Scribe:

Disclaimer: These notes have not been subjected to the usual scrutiny reserved for formal publications.

Consider a positive integer n and p∈[0,1]. Perhaps the simplest model of random (undirected) graphs is Gn,p. To sample a graph from Gn,p, we add every edge {u,v} (for uβ‰ v and u,v∈{1,…,n}) independently with probability p.

For example, if X denotes the number of edges in a Gn,p random graph, then we have

𝔼⁒[X]=(n2)β‹…p.

A 4-clique in a graph is a set of four nodes such that all (42)=6 possible edges between the nodes are present. Let G be a random graph sampled according to Gn,p, and let π’ž4 denote the event that G contains a 4-clique. It will turn out that if p≫nβˆ’2/3, then G contains a 4-clique with probability close to 1, while if pβ‰ͺnβˆ’2/3, then ℙ⁒[π’ž4] will be close to 0. Thus p=nβˆ’2/3 is a β€œthreshold” for the appearance of a 4-clique.

Remark 2.1.

Here we use the asymptotic notation f⁒(n)≫g⁒(n) to denote that limnβ†’βˆžf⁒(n)/g⁒(n)β†’βˆž. Similarly, we write f⁒(n)β‰ͺg⁒(n) to denote that limnβ†’βˆžf⁒(n)/g⁒(n)β†’0.

We can use a simple first moment calculation for one side of our desired threshold behavior.

Lemma 2.2.

If pβ‰ͺnβˆ’2/3 then ℙ⁒[π’ž4]β†’0 as nβ†’βˆž.

Proof.

Let X denote the number of 4-cliques in G∼Gn,p. We can write X=βˆ‘SXS where the set S runs over all (n4) subsets of four vertices in G, and XS be the indicator random variable that there is a 4-clique on S. We have ℙ⁒[XS=1]=p6 since all 6 edges must be present and are independent, thus by linearity of expectation 𝔼⁒[X]=p6β‹…(n4). So if pβ‰ͺnβˆ’2/3, then 𝔼⁒[X]β†’0 as nβ†’βˆž. But now Markov’s inequality implies that

ℙ⁒[π’ž4]=ℙ⁒[Xβ‰₯1]≀𝔼⁒[X]β†’0.

∎

On the other hand, proving that p≫nβˆ’2/3⇒ℙ⁒[π’ž4]β†’1 is more delicate. Even though a first moment calculation implies that, in this case, 𝔼⁒[X]β†’βˆž, this is not enough to conclude that ℙ⁒[π’ž4]β†’1. For instance, it could be the case that with probability 1βˆ’1n2, we have no 4-cliques, but we see all (n4) many 4-cliques otherwise. In that case, 𝔼⁒[X]=Θ⁒(n2), but still the probability of seeing a 4-clique would be 1n2 In other words, if the only thing we know about the random variable X is its expectation we cannot say it is non-zero with high probability. We need to know higher order moments of X.

2.1 Chebyshev’s Inequality

Definition 2.3 (Variance).

The variance of a random variable X is defined as

Var⁒(X)=𝔼⁒[(Xβˆ’π”Όβ’X)2]=𝔼⁒[X2]βˆ’π”Όβ’[X]2
Theorem 2.4 (Chebyshev’s Inequality).

For any random variable X,

ℙ⁒[|Xβˆ’π”Όβ’X|>Ο΅]<Var⁑(X)Ο΅2

In the probabilistic method, the following statement is very handy.

Corollary 2.5.

For any random variable X,

ℙ⁒[X=0]≀Var⁑(X)(𝔼⁒X)2
Proof.

Let Ο΅=𝔼⁒X in the Chebyshev’s inequality. Then,

ℙ⁒[X=0]≀ℙ⁒[|Xβˆ’π”Όβ’X|β‰₯𝔼⁒X]≀Var⁑(X)(𝔼⁒X)2.

∎

Lemma 2.6.

If X is a non-negative random variable, then

ℙ⁒[X>0]β‰₯(𝔼⁒[X])2𝔼⁒[X2].
Proof.

We use the Cauchy-Schwartz inequality: For any two random variables X,Y we can write

𝔼⁒[Xβ‹…Y]≀𝔼⁒[X2]⋅𝔼⁒[Y2].

Having this we write,

𝔼⁒[X]=𝔼⁒[X⁒𝟏X>0]≀𝔼⁒[X2]⁒𝔼⁒[𝟏X>0]=𝔼⁒[X2]⁒ℙ⁒[X>0].

∎

For random variables X,Y let

Cov⁑(X,Y)=𝔼⁒[X⁒Y]βˆ’π”Όβ’[X]⁒𝔼⁒[Y].

In particular, if X,Y is independent, then Cov⁑(X,Y)=𝔼⁒[X⁒Y].

Fact 2.7.

If X=X1+β‹―+Xn, then

Var⁑(X)=βˆ‘iVar⁑(Xi)+βˆ‘iβ‰ jCov⁑(Xi,Xj).

In particular, if all Xi’s are independent then Var⁑(X)=βˆ‘iVar⁑(Xi).

Proof.

First, observe

Var⁑(X)=𝔼⁒(βˆ‘iXi)2βˆ’(π”Όβ’βˆ‘iXi)2

Expanding the terms and combining the terms corresponding to Xi,Xj gives the desired identity. ∎

Lemma 2.8.

If p≫nβˆ’2/3, then ℙ⁒[π’ž4]β†’1 as nβ†’βˆž.

Proof.

Let XS be the indicator random variable of having a clique on S and X=βˆ‘SXS as before. Using 2.5,

ℙ⁒[π’ž4]=ℙ⁒[X>0]β‰₯1βˆ’Var⁑(X)(𝔼⁒X)2

our goal is to show that Var⁑(X)β‰ͺ(𝔼⁒X)2.

First, notice that for any S,

Var⁑(XS)=𝔼⁒[XS]βˆ’(𝔼⁒[XS])2≀𝔼⁒[XS]=p6.

So, βˆ‘SVar⁑(XS)≀(n4)⁒p6.

Now, fix two sets S,T∈(n4). Obviously if |S∩T|≀1, then S,T do not share any ”potential” edges. So, by independence of edges ℙ⁒[XS⁒XT]=ℙ⁒[XS]⁒ℙ⁒[XT]=p12.

On the other hand, if |S∩T|=2. Then,

ℙ⁒[XS⁒XT]=ℙ⁒[XS]⁒ℙ⁒[XT|XS]=p6⁒ℙ⁒[XT|XS]=p11.

The last identity is because since XS occurs we know that there is an edge in the common pair. So, we only need 5 more edges to get XT. Similarly, if |S∩T|=3, then ℙ⁒[XS⁒XT]=p9. In summary,

ℙ⁒[XS⁒XT]={ℙ⁒[XS]⁒ℙ⁒[XT]if ⁒|S∩T|≀1p11if ⁒|S∩T|=2p9if ⁒|S∩T|=3.

It follows that

βˆ‘Sβ‰ TCov⁑(XS,XT) =βˆ‘S(βˆ‘T:|T∩S|=2Cov⁑(XS,XT)+βˆ‘T:|T∩S|=3Cov⁑(XS,XT))
=βˆ‘S(6⁒(nβˆ’42)⁒(p11βˆ’p12)+4⁒(nβˆ’41)⁒(p9βˆ’p12))
≀(n4)⁒(3⁒n2⁒p11+4⁒n⁒p9)

Lastly,

ℙ⁒[X=0]≀Var⁑(X)(𝔼⁒X)2≀(n4)p6+(n4)(3n2p11+3np9))((n4)⁒p6)2≀1+3⁒n2⁒p5+4⁒n⁒p3(n4)⁒p6

Observe that for p≫nβˆ’2/3 the ratio goes to infinity as nβ†’βˆž. ∎