What is the median of three strategy to select the pivot value in quick sort?
I am reading it on the web, but I couldn\'t figure it out what exactly it is? And also
This strategy consists of choosing three numbers deterministically or randomly and then use their median as pivot.
This would be better because it reduces the probability of finding "bad" pivots.
Think simple... Python example....
def bigger(a,b): #Find the bigger of two numbers ... if a > b: return a else: return b def biggest(a,b,c): #Find the biggest of three numbers ... return bigger(a,bigger(b,c)) def median(a,b,c): #Just dance! x = biggest(a,b,c) if x == a: return bigger(b,c) if x == b: return bigger(a,c) else: return bigger(a,b)