Implemented algorithm for min_value and max_value