Group Presentation
Presented By :
Topics: Randomized Algorithms
University of South Asia | CSE | Batch-35 | 2025
1
Introduction of Randomized Algorithms
An algorithm that uses random numbers to decide what to do next anywhere
in its logic is called a Randomized Algorithm. For example, in Randomized
Quick Sort, we use a random number to pick the next pivot (or we randomly
shuffle the array). And in Karger’s algorithm, we randomly pick an edge.
University of South Asia | CSE | Batch-35 | 2025
2
Types of Randomized Algorithms
• Las Vegas Algorithms
• Monte Carlo Algorithms
University of South Asia | CSE | Batch-35 | 2025
3
Las Vegas Algorithms
University of South Asia | CSE | Batch-35 | 2025
A randomized algorithm that always produce correct result
with only variation from one to another being its running
time is known as Las-Vegas algorithm.
OR
A randomized algorithm which always produces a correct
result or it informs about the failure is known as Las-Vegas
algorithm.
4
Monte-Carlo Algorithms
University of South Asia | CSE | Batch-35 | 2025
The computational algorithms which rely on
repeated random sampling to compute their results
such algorithm are called as Monte-Carlo algorithms.
OR
The random algorithm is Monte-carlo algorithms if it
can give the wrong answer sometimes.
University of South Asia | CSE | Batch-35 | 2025 Example- Randomized permutation 5
import random
# Generates a random permutation of the given
array
def random_permutation(array):
# Shuffle the array using the random number Output1: [3, 1, 4, 2, 5]
generator Output2: [5, 4, 1, 3, 2]
random.shuffle(array) Output3: [1, 5, 2, 3, 4]
array = [1, 2, 3, 4, 5]
# Generate a random permutation of the array
random_permutation(array)
# Print the shuffled array
print(array)
University of South Asia | CSE | Batch-35 | 2025 Example- Randomized quick sort 6
import random
def randomized_quick_sort(arr):
if len(arr) <= 1:
return arr
pivot = random.choice(arr) # Select a
random pivot
left = [x for x in arr if x < pivot] Sorted Array: [1, 1, 2, 3, 6, 8, 10]
middle = [x for x in arr if x == pivot]
right = [x for x in arr if x > pivot]
return randomized_quick_sort(left) + middle +
randomized_quick_sort(right)
# Example usage:
arr = [3, 6, 8, 10, 1, 2, 1]
print("Sorted Array:", randomized_quick_sort(arr))
Advantages of Randomized Algorithms 7
Simplicity & Ease of Implementation
Many randomized algorithms are easier to design and implement than
their deterministic counterparts
Improved Performance in Some Cases
They often provide faster or more efficient solutions compared to
deterministic algorithms, especially for complex problems.
Handles Large and Complex Data Well
Can efficiently process large datasets where deterministic algorithms
may be too slow or impractical
University of South Asia | CSE | Batch-35 | 2025
Advantages of Randomized Algorithms 8
Probabilistic Guarantees
Some randomized algorithms provide high-probability guarantees of
correctness, which can be sufficient in many applications.
Useful in Cryptography & Security
Randomized algorithms play a crucial role in cryptography, where
unpredictability enhances security (e.g., RSA encryption, secure key generation).
Bypass Worst-Case Scenarios
Certain problems that have worst-case scenarios in deterministic algorithms
can perform better with randomness (e.g., Quicksort avoids worst-case O(n²)
behavior with random pivots).
University of South Asia | CSE | Batch-35 | 2025
Disadvantages of Randomized Algorithms 9
Lack of Deterministic Guarantees
They do not always guarantee the same output for the same input, making
debugging and reproducibility difficult.
Possibility of Errors
Some randomized algorithms are only correct with a certain probability,
meaning there's a small chance of incorrect results
Higher Resource Consumption in Some Cases
Randomization can sometimes increase computational overhead, especially in
Monte Carlo simulations
University of South Asia | CSE | Batch-35 | 2025
Disadvantages of Randomized Algorithms 10
Hard to Analyze
The probabilistic nature makes performance and correctness analysis
more complex compared to deterministic algorithms.
Dependence on Quality of Randomness
If the random number generator is biased or not truly random, the algorithm
may perform poorly or introduce vulnerabilities.
Not Suitable for Critical Applications
Applications like financial transactions, medical diagnosis, or mission-critical
systems often require guaranteed correctness, making randomized algorithms
risky.
University of South Asia | CSE | Batch-35 | 2025
University of South Asia | CSE | Batch-35 | 2025
THANK YOU
Presented By :