Change:
Looking for anyone proficient with C/C++ to review the imperative and declarative implementations of the algorithm in . Ideally, any person reading the guide should be able to copy this code into a file or site like and be able to compile and run the code as-is - perhaps adding a function and a test array would help make this work and help users understand better. please add any additional comments/concerns you would like addressed as well.
I already have a link that I made to test the recursive selection sort implementation snippet in that file by a PR. This link has the working code with a test array and output logs. I'll make a PR with the code I have. Since the iterative implementation just provides the body of the loop, I think I can create a function for the iterative version, and make my "main" call this too, thereby demonstrating both approaches.

Discussion:
### Implementation in C/C++ <del> #### Iterative Implementation ```C for(int i = 0; i < n-1; i++) { int min_index = i; for(int j = i +1; j < n; j++) { if(a[j] < a[min_index]) { min_index = j; } } swap(&a[i], &a[min_index]); </del> <ins> The following C++ program contains an iterative as well as a recursive implementation of the Selection Sort algoritm. Both implementations are invoked in the `main()` function. ```cpp #include <iostream> #include <string> using namespace std; template<typename T, size_t n> void print_array(T const(&arr)[n]) { for (size_t i = 0; i < n; i++) std::cout << arr[i] << ' '; cout << "n"; </ins> } <del> ``` #### Recursive Implementation ```C int minIndex(int a[], int i, int j) { if (i == j) return i; </del> <ins> int minIndex(int a[], int i, int j) { if (i == j) return i; </ins> int k = minIndex(a, i + 1, j); <ins> return (a[i] < a[k]) ? i : k; } </ins> <del> return (a[i] < a[k])? i : k; } </del> <ins> void recurSelectionSort(int a[], int n, int index = 0) { if (index == n) return; int k = minIndex(a, index, n - 1); if (k != index) swap(a[k], a[index]); recurSelectionSort(a, n, index + 1); } </ins> <del> void recurSelectionSort(int a[], int n, int index = 0) { if (index == n) return; </del> <ins> void iterSelectionSort(int a[], int n) { for (int i = 0; i < n; i++) { int min_index = i; int min_element = a[i]; for (int j = i + 1; j < n; j++) { if (a[j] < min_element) { min_element = a[j]; min_index = j; } } swap(a[i], a[min_index]); } } </ins> <del> int k = minIndex(a, index, n-1); </del> <ins> int main() { int recurArr[6] = { 100,35, 500, 9, 67, 20 }; int iterArr[5] = { 25, 0, 500, 56, 98 }; </ins> <del> if (k != index) swap(a[k], a[index]); </del> <ins> cout << "Recursive Selection Sort"  << "n"; print_array(recurArr); // 100 35 500 9 67 20 recurSelectionSort(recurArr, 6); print_array(recurArr); // 9 20 35 67 100 500 </ins> <del> recurSelectionSort(a, n, index + 1); </del> <ins> cout << "Iterative Selection Sort" << "n"; print_array(iterArr); // 25 0 500 56 98 iterSelectionSort(iterArr, 5); print_array(iterArr); // 0 25 56 98 500 </ins> } ```

* Time Complexity: <b>O(n<sup>2</sup>)</b> * Sorting in Place: <b>Yes</b> * Stable: <b>No</b> ### Visualization * [USFCA](https://www.cs.usfca.edu/~galles/visualization/ComparisonSort.html) * [HackerEarth](https://www.hackerearth.com/practice/algorithms/sorting/selection-sort/visualize/)