Randomized Algorithms

An algorithm that uses random numbers to decide what to do next anywhere in its logic is called Randomized Algorithm.

Examples:


Concept of Expectation

A random variable can take any possible value in its range, so it is important to define the expected value of any random variable.

Expected Value

Expected value of a discrete random variable is R defined as following:

Suppose R can take value r1 with probability p1, value r2 with probability p2, and so on, up to value rk with probability pk.

Then the expectation of this random variable R is defined as:

E[R] = r1*p1 + r2*p2 + … rk*pk

Example:

Given a fair dice with 6 faces, the dice is thrown n times, find expected value of sum of all results.

Notes:

Linearity of Expectation

Let R1 and R2 be two discrete random variables on some probability space, then expected value of R1 + R2 is:

E[R1 + R2] = E[R1] + E[R2]

Probability and Expectation


Mathematical Background


Analyzing Randomized Algorithms


Classification of Randomized Algorithms

Randomized algorithms are classified in two categories:

Example to Understand Classification:

Consider a binary array where exactly half elements are 0 and half are 1. The task is to find index of any 1.

  • Las Vegas algorithm for this task is to keep picking a random element until we find a 1.
  • A Monte Carlo algorithm for the same is to keep picking a random element until we either find 1 or we have tried maximum allowed times say k.
  • The Las Vegas algorithm always finds an index of 1, but time complexity is determined as expect value. The expected number of trials before success is 2, therefore expected time complexity is O(1).
  • The Monte Carlo Algorithm finds a 1 with probability [1 – (1/2)k]. Time complexity of Monte Carlo is O(k) which is deterministic


Applications of Randomized Algorithms




← Previous: Geometric Algorithms

Next: Branch and Bound Approach →