Search code examples
c++sortingselection-sort

Calling a selectionsort function to sort only a part of an array


void selectionsort(int data[ ], size_t n);

How can I call this selectionsort function to only sort a PART of an array? For example, let's say I have an integer ray called intarr with 15 elements. How can I call this function to only sort intarr[3] to intarr[10], for example?


Solution

  • Your function takes a pointer (start) and a length (implicit end).

    Figure it out?

    Hint: there is no mandate that you have to pass a pointer to the start of the array!