Randomized algorithm use randomness in their computations to achieve a desired outcome. By incorporating random choices into their processes, randomized algorithms can often provide faster solutions or better approximations compared to deterministic algorithms.
- Randomized algorithms are mainly classified into Las Vegas and Monte Carlo types.
- Las Vegas algorithms always produce correct results but with variable running time. Examples are Randomized Quick Sort and Random search
- Monte Carlo algorithms have bounded running time but may produce incorrect results with a small probability. Examples are Fermat Method for Primality Testing and Randomized Karger's Algorithm
Introduction
Easy Problems
- Generates one of 3 according to given probabilities
- Generate 0 and 1 with 25% and 75% probability
- Implement rand3() using rand2()
- Birthday Paradox
- Expected Value of an array
- Shuffle a deck of cards
- Generate CAPTCHA and verify
- Index of max occurring with equal probability
- Randomized Binary Search
Medium Problems
- Make a fair coin from a biased coin
- Shuffle a given array using Fisher–Yates shuffle Algorithm
- Expected Number of Trials until Success
- Strong Password Suggester
- QuickSort using Random Pivoting
- Operations on Sparse Matrices
- Estimating the value of Pi using Monte Carlo
- Implement rand12() using rand6() in one line
Hard Problems
- Generate integer from 1 to 7
- Implement random-0-6-Generator using the given random-0-1-Generator
- Random number from stream, with O(1) space
- Random number generator in arbitrary probability distribution fashion
- Reservoir Sampling
- Linearity of Expectation
- Introduction and implementation of Karger’s algorithm for Minimum Cut
- Random Node from a Linked List
- Random Node from a tree
- Freivald’s Algorithm to check if a matrix is product of two
- Random Acyclic Maze Generator
Recommended: