0

To sort an entire C-style array in c++ we say, sort(arr, arr + n); where n is the length of array. Why does the function requires one index past the last index in array?

  • how would you sort an empty array when the 2nd parameter would not be one past the last element? – 463035818_is_not_an_ai Jun 24 '20 at 12:17
  • Because it's the end of the array. The array doesn't end before the last element, it ends after the last element (or before where the next one would be, if there was one) – user253751 Jun 24 '20 at 12:31

0 Answers0