Implement median search