# CMU Randomized Algorithms

Randomized Algorithms, Carnegie Mellon: Spring 2011

## Monthly Archives: January 2011

## And Lecture #6 references

Some references from class yesterday: a short-and-sweet analysis for Johnson’s algorithm for MAX-SAT satisfying clauses is by Engebretsen; this simplifies the original proof by Chen, Friesen and Zhang. Recall that this analysis is tight if you take the clauses and consider the variables in the order : we could break ties badly and set and get whereas OPT is .

While it would seem that we’ve done all we can with this algorithm, the latest SODA conference has two interesting papers on the subject:

- The paper
*Randomized greedy: new variants of some classic approximation algorithms*by Costello, Shapira, Tetali, which shows that considering the variables in a random order in Johnson’s algorithm achieves a performance of for some constant . - Another paper
*Randomized Variants of Johnson’s Algorithm for MAX SAT*by Poloczek and Schnitger shows that this random order idea cannot achieve , sadly. However, they give a variant of Johnson’s algorithm that does get .

Several questions remain: can we pin down better the performance of Johnson’s algorithm using a random order? It would be interesting to understand these papers, and perhaps to simplify the algorithm or the analysis in the latter? Can it be viewed as implicitly solving a linear program?

**Update:** And here are some lecture notes for MAX-3-SAT from the previous time Avrim taught the course.

## Notes on Lecture 6

**1. The Derandomization for Independent Sets **

Here’s the derandomization of the probabilistic argument for Turan’s theorem. It’s just a little trickier than I’d figured, but it also leads to a different algorithm! (See Section 2.)

Let’s recall the randomized version: Given graph and permutation , call a vertex a *winner* if it appears before all its neighbors in the order . Let be the indicator of being a winner according to permutation , and hence . Now the number of winners , and hence . The greedy algorithm which considers the vertices in the order will at least pick all the winners. Hence,

The issue now is that we now don’t have an exact expression for the expected size of the independent set found by greedy that we can track, we only have a *lower bound* on it, namely the expected number of winners. But that’s OK: we’ll just track this lower bound instead, which we will call the “pessimistic estimator”. Let’s now pin this down.

First, given any set of vertices , if we run the random permutation algorithm on the induced graph , we can compute the expected number of winners exactly — it’s just , where is the degree of in graph .

So let’s do the following: having added some nodes to our independent set, let be the “rest” of the nodes which are not already chosen in nor already ruled out because they are adjacent to some node in . Now define the “*pessimistic estimator*” to be

Note that we start off with empty, then we get . And finally, , then this is just . So if we could ensure that at every step the value never decreases, we’d be done. One can do it in two ways (at least), here’s the approach some of you mentioned at the end of lecture.

** 1.1. Showing a Good Vertex to Add **

Consider all the possible vertices in : we’ll show one of them can be added to to cause . For vertex , let be its neighbors (including itself) in . If we add in to the I.S., the new value would be

The inequality is because the degrees in can never be larger than those in . Now rewriting,

If we average over all , and we get

which is non-negative since for each (of which there are at most , there are many ‘s. And hence, there is at least one to add so that .

The part that originally threw me off in the calculations was that averaging over the ‘s could potentially lead to a greater potential than what we started off . But that is only better for us, so all’s well.

** 1.2. So To Summarize **

The final idea is this: for the probabilistic analysis, we didn’t know how to compute the expectation we wanted (i.e., the expected number of vertices picked by random-permutation greedy). So we used a lower bound—the expected number of winners.

And then, that lower bound was useful for the derandomization. We show that we could add in one vertex at a time to the independent set while never decreasing plus the expected number of winners in the rest.

**2. BTW, A Simpler Algorithm **

If we go back and stare at inequality (1) for a few minutes, we realize that this analysis also gives an analysis for the following greedy algorithm:

While there is a vertex left in the graph, add the vertex with lowest remaining degree into , and remove it and all its neighbors.

(Do you see why?) We’ve shown that this will give an independent set of size at least .

**3. Pessimistic Estimators for Low Congestion **

The general method of pessimistic estimators is attributed to Prabhakar Raghavan, whose book is the text for the course, and who’s currently the head of Yahoo! Research. (He did this work while he was a graduate student in the mid-80s.)

His original paper used pessimistic estimators to derandomize, among other problems, the randomized-rounding algorithm for low-congestion routing example we saw in the previous lecture (due to Raghavan and Thompson). Aravind Srinivasan has some great notes on the derandomization; here’s a high-level summary.

Prabhakar’s use of these estimators is very neat, since looking at the proof it’s not obvious what to use as the pessimistic estimator, since there’s the Chernoff bound, which seems somewhat mysterious and awkward to handle. So he unrolls the first few steps of the Chernoff-bound calculation, which you recall goes as follows: if is the congestion on an edge , then

where the sum over edges represents the union bound, we use Markov’s inequality in the middle, all the m.g.f. calculations are omitted here, and is suitably chosen to ensure the bound of .

He then notes that the expression upper bounds the actual probability of error, and also can be tracked efficiently. In particular, fixing flow-paths for some of the source-sink pairs, we can calculate the expectation over random choices for the rest of the pairs, since these ‘s are sums of independent random variables. And we can make choices that causes this quantity to not increase. So if the estimator starts off below , we ensure it always stays below that quantity.

And since the final probabilities are integers or (since we’ve chose one flow-path for each source-sink pair, either an edge has more than congestion, or it does not), and they sum to less than , they must all be zero. This gives the deterministic algorithm with congestion at most .

Again, Aravind’s notes, or the original paper, give you more details, and a more general properties that suffice for pessimistic estimators.

## Heads-up for today’s lecture

Today’s lecture will not have notes (like the great ones Avrim’s been handing out), sorry! So you might want to bring along some paper and pencils to take your own notes. ðŸ™‚

Also, if you have a minute, look over the randomized rounding algorithm/proof for low-congestion routing we saw in the previous lecture: we’ll try to talk about its derandomization today (among other things).

## Belated Notes on Lecture #2

*(Sorry for the delayed notes: it made sense to wait until we’d seen Chernoff bounds before I posted these. — AG)*

We saw in Lecture #2 that the expected number of comparisons for the randomized version of quicksort was at most ; the proof was via defining just the right random variables (*“do we compare and at any step”*), we could compute that , and hence the expected number of comparisons is .

However, often it helps to get a quick ballpark estimate before going for the best analysis: here’s a quick-and-dirty way to see that the number of comparisons for Quicksort is with probability at least for some other constant that depends on . Not only does this imply that the expected number of comparisons is (why?), but also that the number of comparisons is very unlikely to be much larger than the expectation.

Here’s the theorem for today:

Lemma 1With probability at least , the number of levels of recursion in Quicksort is at most .

*Proof:*

First, let level comparisons be those done when we partition the entire input into two parts, level comparisons be those when we partition these two parts into two parts each, and so on. Note that the number of comparisons made in level is at most , so it suffices to show that the number of levels before all the parts have only a single element each is with high probability.

Let’s prove this claim. Consider a single element . Let be the set containing at level . Note that is the entire input. We call level to be -good if either , or the level- pivot falls in the middle half of and hence causes to be at most . Since we pick a pivot uniformly at random, the chance of any level being -good is at least , independent of all other levels. Hence, probability of seeing at least -good levels within the top levels is at least the probability of seeing heads in flips of an unbiased coin. (I.e., the number of -good levels stochastically dominates the Geom() random variable.)

Note that if there are -good levels, then since a good level reduces the size of the set by at least , the element must lie in a set of unit size. Setting , the chance of seeing fewer than good levels is at most the chance of seeing fewer than heads when we expect to see heads. By a multiplicative Chernoff bound on the lower tail, the chance of this is at most

Thus the branch of the recursion containing the element terminates before levels except with probability . There are possible elements, and we can take a trivial union bound over these elements: with probability at least , the Quicksort recursion must have bottomed out before levels.

Note that this shows the total number of comparisons is bounded by with probability .

But what about the **expected** number of comparisons? One can bound this in several ways. Here’s one: with probability the “good event” happens and the number of comparisons is at most . If the good event does not happen (w.p. ), we know that Quicksort takes comparisons in the worst case, and hence the expected number of comparisons is at most

This is much worse than the bound of we showed in class, but it has two advantages: (a) it was quick and dirty, as promised, and (b) it also shows a concentration result—Quicksort is unlikely to do many more comparisons than you’d expect.

In fact, one can prove much better bounds: a result of McDiarmid and Hayward from SODA 1992 shows that if is r.v. denoting the number of comparisons for Quicksort, then falls outside the interval with probability

That’s pretty well-concentrated! (One class project could be to understand this paper, and the concentration results they use.)

## Notes on Lecture #5

A couple of things I remembered about Chernoff bounds when sitting in Avrim’s lecture, which thought I’d post here.

The first thing is a (slightly different) bound that you may find easier to remember. To begin, let us state the multiplicative bounds mentioned in the handout, altered ever so slightly:

Theorem 1

Let be independent variables, and let . Let . Then for any ,

Now, here’s the version of the general multiplicative bounds I find easiest to remember:

Theorem 2

Let be independent variables taking values in the range , and let . Let . Then for any ,

Note that we’ve relaxed the assumption that ‘s are , and are allowing ourselves to lie in . (This is often super-useful, you may want to go over the proof of Theorem 1 in the book or the handout and think about how you may prove it.)

Moreover, (4) is exactly the same as (1). And if we constrain , the exponent on the right of (5) is at most , which is the same as in (2), so (5) is a better bound than (2) for ‘s in this range. So we’re doing at least as well as the first two tail bounds in Theorem 1.

Cool! So does this subsume (3) as well? Sadly, no. We lose something in the translation. Here’s an example. Let the ‘s be i.i.d., taking on value with probability and otherwise, so that . Now, what is the value of which gives us a tail probability of ? If we set for suitably large then (3) gives us , but for (5) to fall below we need for some constant .

However, often the bound from (5) is in the “right ballpark”, and I find it easy to remember. Chances are, if I use a Chernoff bound in lecture, it’ll be the one in Theorem 2.

Secondly, some jargon: these bounds are often called *concentration inequalities* (since they show that “most of the probability mass is concentrated around the mean”) and *tail bounds* (they show that the “tails of the distribution are small”) or *large deviation bounds* (since they show that “large deviations from the mean are unlikely”). There are tons of other tail bounds, some relaxing the requirements of independence, others relaxing the boundedness requirements, others looking at functions other than the sum of the random variables—you’ll see more in the homeworks and future lectures.

## Homework #1 Open Thread

Jeremiah just pointed out that Problem 2(a) analyzing the 3SAT algorithm was missing a couple terms from the summation. The online version has been fixed.

## Another Algorithm for SAT

BTW, when solving HW#1 Problem #2, it may be interesting to try solve the problem for -SAT. The algorithm remains the same, and you should be able to show a success probability of approximately . As a sanity check, for this is again .

So here’s a different randomized algorithm to solve -SAT in less than time. This one is from a paper titled Satisfiability Coding Lemma due to Ramamohan Paturi, Pavel Pudlak and Francis Zane. Hence, we’ll call this the PPZ algorithm.

Pick a random permutation on the variables. Pick a uniformly random “start” assignment for the variables. Now consider the variables in the order , and do the following:

If the current variable is the only remaining variable for some clause, set it to satisfy that clause. (If occurs positively in some clause and negatively in some other clause, you can abort the process at this point.) If the current variable only occurs in clauses with more than one variable, set it equal to .

Now, setting this variable to or will cause some clauses to be satisfied: remove these clauses. In other clauses, this variable will just disappear. E.g., if a clause was and we set to , then the new clause will just be . Do all these simplifications, and then go on to the next variable.

That’s it. To recap, we just pick a random variable, if it is forced (due to some clause of length ), set it to the forced value, else set it randomly. Continue until we have a complete assignment.

A theorem due to PPZ says:

Theorem 1

Given a satisfying -SAT formula, the probability that this algorithm finds a satisfying assignment is at least .

Hence for , this gives an algorithm with expected running time approximately . Not quite as good as Sch\”{o}ning’s algorithm, but not too bad! And the proof is also very clean. In this post we’ll just consider the case where there is a unique satisfying assignment . (The general case is not much harder, see Section~4.1 in the PPZ paper.)

So yeah, there’s a unique satisfying assignment . This means that for every variable , changing the value of to will give us an unsatisfying assignment, and some clause will complain because it is not satisfied any more; if there are several, pick any one. Call this a critical clause for variable , and name it . OK, variables, each with its very own critical clause.

Why these critical clauses? Suppose in the clause , we’ve set the other variables to be the same as in . Then the only way to satisfy will be to also set equal to . And, if it turns out that in the random order we’re considering the variables, if came after all the other variables in , this is precisely what the PPZ algorithm will do! Indeed, it will not have to make a random choice for : our hand will be forced to choose .

So suppose for a random permutation, call a variable *lucky* if among the variables in their critical clause, places last in the ordering . And be the set of lucky variables for permutation . Then, assuming that we lucked out and chose for all the variables , the algorithm will certainly also set to . So, for the permutation , the chance (over the choice of ) that we find the satisfying assignment is .

Finally, what is , the expectation taken over random permutations ? Rewriting, it is . By convexity, the numerator is at least . And what is the expectation? See, there are variables. Each one has a chance to be lucky and placed last in its critical clause, and so the expected size of is . So our success probability is at least , proving the theorem for the unique assignment case.

A couple of notes: Firstly, you can think of the PPZ algorithm as a randomized non-backtracking Davis-Putnam procedure. You’ll probably hear about DPLL algorithms (named after Martin Davis, Hilary Putnam, George Logemann, and Donald Loveland) sooner or later, if you haven’t already; so if you’re interested, check out these notes by Satish Rao.

Secondly, the PPZ algorithm can be improved. After their paper, Paturi, Pudlak and Zane teamed up with Mike Saks to give us the PPSZ paper (here, here). Their new algorithm first does some simple preprocessing (a few steps of resolution, since you ask), and then runs the PPZ algorithm. The new PPSZ analysis beats Sch\”{o}ning’s performance of for and higher.

Moreover, as we mentioned in this post, the two algorithms work better in somewhat orthogonal cases: Sch\”{o}ning’s algorithm works better when there are many “well-spread” satisfying assignments, and PPSZ works better with “few” solutions. And the papers of Iwama and Tamaki, and Hertli et al., combine these two algorithms carefully to get the current world record algorithms. Can you beat this world record?

## Lecture 1 notes and references

The reference to the best known algorithm for 3SAT we mentioned in class is this paper: Improving PPSZ for 3-SAT using Critical Variables, by Hertli, Moser, and Scheder.

It gives a algorithm with an expected runtime of 1.321^n, and the idea to cleverly combine Schoening’s algorithm (the one you saw today and will analyze in HW1) and a previous algorithm of Paturi, Pudlak, Saks and Zane (PPSZ).

At a super-high level, Schoening’s algorithm does better if there are lots of (well-separated) solutions that the randomized process can make a beeline for. The PPSZ algorithm, another very simple randomized algorithm that we may see in a later post, works better if there are few satisfying assignments. The idea in the paper of Hertli and others is how to trade off the two guarantees to do better than either one individually; this idea of combining Schoening and PPSZ goes back to a paper of Iwama and Tamaki (SODA ’04).