+1 vote
by
What is this C++ function? What is the name of the algorithm?
void SortArr(int arr[], int n) {
for (int startIndex = 0; startIndex < n - 1; ++startIndex) {
int smallestIndex = startIndex;
for (int currentIndex = startIndex + 1; currentIndex < n; ++currentIndex) {
if (arr[currentIndex] < arr[smallestIndex]) {
smallestIndex = currentIndex;
}
}
swap(arr[startIndex], arr[smallestIndex]);
}
}

2 Answers

+1 vote
by
Read algorithm descriptions , look for the one that matches the code shown.
by
So by bubble or choice?
by
There's an article on hubra with implementations of all these sorts, I couldn't find any of them similar.
by
NQUARE , bubble sorting
by
NQUARE What does this have to do with some article on the hubra?
by
NQUARE Who are you asking now? If it's me, I've already shown you the way to your own solution, so think about it. If it's "bubble" - he didn't hear you, in order for the user to be notified of the reply he received, it must contain his name.
+1 vote
by
...