implented the algorithm that selects the k closest elements to the median.