Randomized Algorithms Last Updated : 23 Jul, 2025 Comments Improve Suggest changes Like Article Like Report 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). We use randomization in Quick Sort to avoid a pattern for which it always causes a worst case. This is useful when we implement a library sort function using Quick Sort as it allows the library function to be a general purpose function and work almost uniformly for all cases.IntroductionIntroduction and AnalysisClassification and Applications1/2 Approximate Median ExampleEasy Problems Generates one of 3 according to given probabilitiesGenerate 0 and 1 with 25% and 75% probabilityImplement rand3() using rand2()Birthday ParadoxExpected Value of an arrayShuffle a deck of cardsGenerate CAPTCHA and verifyIndex of max occurring with equal probabilityRandomized Binary SearchMedium Problems Make a fair coin from a biased coinShuffle a given array using Fisher–Yates shuffle AlgorithmExpected Number of Trials until SuccessStrong Password Suggester ProgramQuickSort using Random PivotingOperations on Sparse MatricesEstimating the value of Pi using Monte CarloImplement rand12() using rand6() in one lineHard Problems Generate integer from 1 to 7 with equal probabilityImplement random-0-6-Generator using the given random-0-1-GeneratorSelect a random number from stream, with O(1) spaceRandom number generator in arbitrary probability distribution fashionReservoir SamplingLinearity of ExpectationIntroduction and implementation of Karger’s algorithm for Minimum CutSelect a Random Node from a Singly Linked ListSelect a Random Node from a tree with equal probabilityFreivald’s Algorithm to check if a matrix is product of twoRandom Acyclic Maze Generator with given Entry and Exit pointRecommended:Learn Data Structure and Algorithms | DSA Tutorial Comment H harendrakumar123 Follow Improve H harendrakumar123 Follow Improve Article Tags : DSA Explore DSA FundamentalsLogic Building Problems 2 min read Analysis of Algorithms 1 min read Data StructuresArray Data Structure 3 min read String in Data Structure 2 min read Hashing in Data Structure 2 min read Linked List Data Structure 2 min read Stack Data Structure 2 min read Queue Data Structure 2 min read Tree Data Structure 2 min read Graph Data Structure 3 min read Trie Data Structure 15+ min read AlgorithmsSearching Algorithms 2 min read Sorting Algorithms 3 min read Introduction to Recursion 14 min read Greedy Algorithms 3 min read Graph Algorithms 3 min read Dynamic Programming or DP 3 min read Bitwise Algorithms 4 min read AdvancedSegment Tree 2 min read Binary Indexed Tree or Fenwick Tree 15 min read Square Root (Sqrt) Decomposition Algorithm 15+ min read Binary Lifting 15+ min read Geometry 2 min read Interview PreparationInterview Corner 3 min read GfG160 3 min read Practice ProblemGeeksforGeeks Practice - Leading Online Coding Platform 6 min read Problem of The Day - Develop the Habit of Coding 5 min read Like