[Solved]: Does a coin tossing algorithm terminate?

Problem Detail: Suppose we have an algorithm like:

n = 0 REPEAT   c = randomInt(0,1)   n = n + 1 UNTIL (c == 0) RETURN n 

(Assumuing the random number generator produces “good” random numbers in the mathematical sense.) I understand that there is no number $n in mathbb{N}$ such that the algorithm is guaranteed to terminate after fewer than $n$ steps. However, the probability of terminating after some finite number of steps is 1. Is there a convention among computer scientists to call an algorithm like this either “terminating” or “non-terminating”?

Asked By : alondra_gomez

Answered By : Gilles

The formal, unambiguous way to state this is “terminates with probability 1” or “terminates almost surely“. In probability theory, “almost” means “with probability 1”. For a probabilistic Turing machine, termination is defined as “terminates always” (i.e. whatever the random sequence is), not as “terminates with probability 1”. This definition makes decidability by a probabilistic Turing machine equivalent to decidability by a deterministic Turing machine supplied with an infinite tape of random bits — PTM are mostly interesting in complexity theory. In applied CS, though, computations that always give the correct result but terminate only with probability 1 are a lot more useful than computations that may return an incorrect result.
Best Answer from StackOverflow

Question Source : http://cs.stackexchange.com/questions/32944