input: Write a function to find the minimum and maximum values in an array. If the array is empty, the function should return None for both the minimum and maximum values. If the array has only one element, it will be considered both the minimum and maximum value.
  assert min_max([3, 4, 5, 1, 2])==(1, 5)
  assert min_max([6, 2, 8, 1, 9, 5])==(1, 9)
  assert min_max([7])==(7, 7)
  assert min_max([])==(None, None)
  def min_max(array):
      if not array:
          return None, None
      min = array[0]
      max = array[0]
      for val in array[1:]:
          if val < min:
              min = val
          if val > max:
              max = val
      return min, max
output: def min_max(array):
      if not array:
          return None, None
      min_val = max_val = array[0]
      for val in array[1:]:
          if val < min_val:
              min_val = val
          if val > max_val:
              max_val = val
      return min_val, max_val