Implement Median of Medians algorithm