O'Reilly logo

Theory of Computational Complexity, 2nd Edition by Ker-I Ko, Ding-Zhu Du

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 8

Probabilistic Machines and Complexity Classes

Once you have mathematical certainty, there is nothing left to do or to understand.

—Fyodor Dostoevsky

We develop, in this chapter, the theory of randomized algorithms. A randomized algorithm uses a random number generator to determine some parameters of the algorithm. It is considered as an efficient algorithm if it computes the correct solutions in polynomial time with high probability, with respect to the probability distribution of the random number generator. We introduce the probabilistic Turing machine (PTM) as a model for randomized algorithms and study the relation between the class of languages solvable by polynomial-time randomized algorithms and the complexity classes P and NP.

8.1 Randomized Algorithms

A randomized algorithm is a deterministic algorithm with the extra ability of making random choices during the computation that are independent of the input values. Using randomization, some worst-case scenarios may be hidden so that it only occurs with a small probability, and so the expected runtime is better than the worst-case runtime. We illustrate this idea by examples.

Example 8.1

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required