Skip to content

gkontogiannhs/Lazy-Select-Algorithm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

The Lazy Select Algorithm

This algorithm finds the k-th smallest element in a set S of n elements. The algorithm works by randomly selecting a subset R of n^(3/4) elements from S and sorting it. Then, the algorithm determines two elements a and b from R such that the k-th smallest element in S is likely to be between a and b. The algorithm then creates a new set P consisting of all elements in S that are between a and b, and sorts P. Finally, the algorithm returns the k-th smallest element in P. The algorithm repeats these steps until it finds the correct result or a predetermined number of iterations is reached. The Lazy Select Algorithm is a randomized algorithm performing 2n + o(n) comparisons in the worst case and average time complexity of O(n^(2/3)). The Lazy Select Algorithm finds the correct solution with high probability. The probability of finding the correct solution is 1 - O(n^(-1/4)), meaning that the probability of error decreases as n increases.