CS 627 – Advanced Algorithms (Winter 2026-27) · unit page · YouTube
2026-11-26, 8:04

← Video 7-4: Probabilistic Turing Machines

Click any sentence to play from there.

The transcript was generated automatically by YouTube's speech recognition and is offered as is. It may contain errors, in particular concerning technical terms, names and formulas.

0:03 In the next section, let's look at how we can uh build algorithms based on these randomized computations or the randomized probabilistic during machines. And there's basically two options. Uh there's if you want to play games with random things, then you go to a casino and these are famously either in Las Vegas or in Monte Carlo. Uh that terminology is stuck and there's no particular good reason. I think people found it fun. A Las Vegas randomized algorithm is one that is always outputting the correct answer. It just may use randomness to guide its decisions and maybe it takes more or less time based on the random bits but it always has the right output. [snorts] Suppose we want to compute some some general function. It maps uh some string some strings to some other strings. Um this is a as a special case our usual decision problems where we have the yes instances out of all the allowed instances. That's of course also one of these. Then the function that we compute is just um the indicator function.

1:13 Uh this is just a unified annotation. So a Las Vegas random algorithm uh is an algorithm that satisfies these three properties. First of all, it always terminates with probability one. Almost surely terminates. Then um its output is is always correct except that it can also sometimes say ah sorry I'm I failed. This is better than you'll see the difference in a bit. This is way more useful than just outputting some random value like LLMs. I'm looking at you. Uh, also it should be correct at least half the time. Again, okay, you can I'm not continuing the joke. That's a Las Vegas algorithm. So, it never outputs something that's just know unknowingly wrong.

2:05 You can even refer refine this further. We'll stick to this definition because it's also standard. uh but you can show if you have a Las Vegas algorithm for some function then you can transform it into one that always uh spits out the right answer and never says this ah I'm not sure I'm sorry um it always is correct and you can say something about its expected running time not its worst case time but the expected time is at most two times the running time in the worst over The worst case over again remember this was worst case over all the random bits over row and this factor two maybe um gives away what you're what you have to do but you'll have to do this the exercises. Uh but maybe this has to wait a week because we're not going to be able to cover the technique for it. Darn. Um, this is the version where you don't allow the uh I don't know, but you're willing to compromise a bit on the running time because there's a reason why it only bounced the expectation. Uh, the other option is kind of the the converse. Um, suppose you have um a randomized algorithm B that computes a function precisely. So, probability to be correct is one and you have some upper bound for its expected time.

3:39 uh it just shouldn't be infinite. then you can transform it into an algorithm that has a worst case bound for its time and again it's it's twice as much as this uh upper bound on the expected time and now this one is at least uh correct with probability 1/2 and the other you know the other parts it says ah I failed sorry again um you look at this it's rather easy but I think it's insightful to think about. So it means for Las Vegas uh it doesn't seem to matter all that much whether you allow one or the other. You can always trade one for the other. You can trade expected time for worst case by allowing this don't know outcome or vice versa. Uh we'll name these because it's sometimes convenient to use one or the other as the always decisive Las Vegas algorithms. Hopefully that's self-explanatory. That's the ones that never say don't know. and the always terminating one has a fixed bound on the worst case running time but may say don't know sometimes.

4:46 Uh you can think about whether you can forbid both at the same time. Uh let me show you um a few examples. Uh one is indeed this algorithm we've seen before with um the rejection sampling die roll. It never outputs something wrong. Now you can um have it in two ways. The version we've had before was always correct. It never said don't know because there was no way it said anything but a number, but it might not terminate. So, it was the always decisive version. You can always um move between these two. Here's the example for the always terminating one. You just try once and either it worked or it didn't. And then you output don't know. And uh there are of course restricted cases like quicksort and quick select. They even are both right. They're always correct and they always terminate. They are even more restricted. So uh ven diagram. Yeah. Always decisive, quick sort.

6:06 You can have both and there's sensible examples where you can have both. In general, we allow at least one of the two. Um, last slide I promise is the alternative. It spoke about Las Vegas. There's also Monte Carlo algorithms. Europeans are a bit less a bit more more lenient. Um it's okay to sometimes be just wrong. You can out output some arbitrary value and formally we say an algorithm is a Monte Carlo algorithm. If here we we restrict to be always terminating can again we'll look at the conversions maybe. Uh so a Monte Carlo algorithm for some function again uh is bounded error Monte Carlo if the probability to output the correct answer is greater or equal 1/2 with a little bit of distance from 1/2 and it's unbounded error Monte Carlo if well it's still bounded but only as strictly greater 1/2 which means as a function of X the probability to compute the right value might go to 1/2. have and you'll see that this is indeed a problem. These are kind of useless. These second ones in general, you cannot use them for much. These ones are useful. So bounded error Monte Carlo is what we'll mostly uh work with at the level of this definition. It seems like like a nitpick greater equal 1/2 plus epsilon and strictly greater 1/2 feels like it's not a difference. But the dependence on x makes uh makes the difference or the order of the quantifiers. Right here it says for every epsilon there's an epsilon so that for all x this is a bound here because it doesn't say an epsilon it's effectively for every x there is an epsilon quantifier is flipped.