 The variable bucket size of bucket sort allows it to use O("n") memory instead of O("M") memory, where "M" is the number of distinct values; in exchange, it gives up counting sort's O("n" + "M") worst-case behavior.Bucket sort with two buckets is effectively a version of quicksort where the pivot value is always selected to be the middle value of the value range.While this choice is effective for uniformly distributed inputs, other means of choosing the pivot in quicksort such as randomly selected pivots make it more resistant to clustering in the input distribution.