Ad
  • Custom User Avatar

    1 is what your function wrongly returned, not the input value.

  • Custom User Avatar

    Closing.

  • Custom User Avatar

    It's the minimum from the previous step. It shows a continuity, what we might call an 'induction hypothesis'. If min was the minimum from the previous step, and we take the minimum between that and the number we are currently looking at, we know that what we return is the minimum over all (so far), right? So we know we will end up with the minimum of all the numbers once we're done.

    But I accept your criticism about the naming. prevMin would have been clearer.

    Honestly I'm more upset about the initial, though. available is so much better.

  • Custom User Avatar

    Because you have an infinite loop under certain conditions. Print the input.