Algorithm Design: Randomized Algorithms

Understand randomized algorithm technique with the help of QuickSort algorithm.

Randomized algorithms

Suppose you hear your phone ringing somewhere in your house. If you happen to have a coin, then before even starting to search for the phone, you could toss it to decide whether you want to start your search on the first floor if the coin comes up heads, or on the second floor if the coin comes up tails. If you also happen to have a die, then after deciding on the second floor of your mansion, you could roll it to decide in which of the six rooms on the second floor to start your search.

Although tossing coins and rolling dice may be a fun way to search for the phone, it is certainly not the intuitive thing to do, nor is it at all clear whether it gives you any algorithmic advantage over a deterministic algorithm.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.