Min and max elements with minimum comparisons