Easy Problems on Randomized Algorithms
- Write a function that generates one of 3 numbers according to given probabilities
- Generate 0 and 1 with 25% and 75% probability
- Implement rand3() using rand2()
- Birthday Paradox
- Expectation or expected value of an array
- Shuffle a deck of cards
- Program to generate CAPTCHA and verify user
- Find an index of maximum occurring element with equal probability
- Randomized Binary Search Algorithm
Randomized Algorithms
Randomized algorithms in data structures and algorithms (DSA) are algorithms that use randomness in their computations to achieve a desired outcome. These algorithms introduce randomness to improve efficiency or simplify the algorithm design. By incorporating random choices into their processes, randomized algorithms can often provide faster solutions or better approximations compared to deterministic algorithms. They are particularly useful in situations where exact solutions are difficult to find or when a probabilistic approach is acceptable.
For example, in Randomized Quick Sort, we use a random number to pick the next pivot (or we randomly shuffle the array). Typically, this randomness is used to reduce time complexity or space complexity in other standard algorithms.