Randomized Selection Algorithm

the key idea is to use the quicksort partitioning scheme in which we reduce our selection problem size into half(just the expectation).


T(n) = O(n) + T(n // 2)

the resulting algrithm is a O(n) algo…
if anyone faced a problem similar to RMID2 but having very less queries but large data stream then it is better to use the randomized selection’s O(1) insertion and O(n) query rather than two priority queue method’s O(log(n)) insertion and O(log(n)) query..

here’s my implementation..

https://gist.github.com/929264ea9a05aa0956c5

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s