Randomized Algorithms Classification and Applications (original) (raw)
Last Updated : 20 Jan, 2026
Randomized algorithms are classified in two categories.
1. **Las Vegas
A Las Vegas algorithm is an algorithm which uses randomness, but gives guarantees that the solution obtained for given problem is correct.
- Always produce a _correct answer. Randomness affects the running time, not correctness. Expected running time is finite and analyzed probabilistically
- A randomized quick-sort algorithm where we randomly choose pivot is an example of Las-Vegas algorithm. The algorithm always sorts the array. The advantage we get with randomization is, there is no pattern for which the quick sort causes worst case (unlike choosing fixed pivot like a corner element causes worst case for sorted input)
- Time complexity of these algorithms is based on a random value and time complexity is evaluated as expected value. For example, Randomized Quick Sort always sorts an input array and expected worst case time complexity of Quick Sort is O(nLogn).
2. **Monte Carlo:
A random algorithm is Monte-carlo algorithms if it can give the wrong answer sometimes.
- Running time is typically _fixed or bounded.
- Output may be incorrect with a small probability.
- Often used when approximate answers are acceptable or when error probability can be made tiny. These algorithms are used for solving physical simulation system and mathematical system.
- For example this implementation of Karger's Algorithm produces minimum cut with probability greater than or equal to 1/n2 (n is number of vertices) and has worst case time complexity as O(E). Another example is Fermat Method for Primality Testing.
The Monte-carlo methods are used in places where deterministic algorithms take a lot time. Monte carlo integration is the most common application of Monte-carlo algorithm. There are various methods used for integration by using Monte-carlo methods such as,
i) Direct sampling methods which includes the stratified sampling, recursive stratified sampling, importance sampling.
ii) Random walk Monte-carlo algorithm which is used to find out the integration for given problem.
iii) Gibbs sampling.
**Example to Understand the above Classification:
Consider a binary array where exactly half elements are 0 and half are 1. The task is to find index of any 1.
- A 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
- Consider a tool that basically does sorting. Let the tool be used by many users and there are few users who always use tool for already sorted array. If the tool uses simple (not randomized) QuickSort, then those few users are always going to face worst case situation. On the other hand if the tool uses Randomized QuickSort, then there is no user that always gets worst case. Everybody gets expected O(n Log n) time.
- Randomized algorithms have huge applications in Cryptography.
- Load Balancing.
- Number-Theoretic Applications: Primality Testing
- Data Structures: Hashing, Sorting, Searching, Order Statistics and Computational Geometry.
- Algebraic identities: Polynomial and matrix identity verification. Interactive proof systems.
- Mathematical programming: Faster algorithms for linear programming, Rounding linear program solutions to integer program solutions
- Graph algorithms: Minimum spanning trees, shortest paths, minimum cuts.
- Counting and enumeration: Matrix permanent Counting combinatorial structures.
- Parallel and distributed computing: Deadlock avoidance distributed consensus.
- Probabilistic existence proofs: Show that a combinatorial object arises with non-zero probability among objects drawn from a suitable probability space.
- Derandomization: First devise a randomized algorithm then argue that it can be derandomized to yield a deterministic algorithm.