Question: I've gotten yet another compiler error. Do I need another print function? The error is the same as last time (Id returned 1 exit status).

I've gotten yet another compiler error. Do I need another print function? The error is the same as last time (Id returned 1 exit status). The only thing that's different is I fleshed out the select_sort function

#include using namespace std; int const asize = 10; void initialize(int[], int, int); void print(int[], int, int); int find_min_index(int[], int, int); void select_sort(int[], int, int); int main() { int list[asize]; initialize(list, 0, asize - 1); select_sort(list, 0, asize - 1); print(list, 0, asize - 1); return 0; } void initialize(int array[], int start, int end) { if (start <= end) { cout << "[" << start << "] > " << flush; cin >> array[start]; initialize(array, ++start, end); } } void print(int array[], int start, int end) { if(start <= end) { cout << array[start] << " "; print(array, ++start, end); } } int find_min_index(int array[], int Lindex, int Cindex, int size) { //write something not a loop to find min

if (Cindex < size) { if (array[Lindex] > array[Cindex]) { Lindex = Cindex; } return find_min_index(array, Lindex, Cindex++, size); } return Lindex; } void select_sort(int array[], int s, int index = 0) { //where the sorting actually goes //look up how to do selection sort recrusively //try doing it normally then converting it if(index == s) return; int Lindex = find_min_index(array, s, index); if(Lindex != index) swap(array[Lindex], array[index]); select_sort(array, index++, s); }

I'd also appreciate it if I was explained to me how to avoid these kinds of errors as I seem to be running into them more often. Please and thank you

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!