Question: For this program you will first read in 10 integers and store them in an array. Then you will then sort the array using a

For this program you will first read in 10 integers and store them in an array. Then you will then sort the array using a recursive version of selection sort. You are to design a recursive version of selection sort your self. The basic idea should be:

Find the smallest element in the array.

Swap the smallest element with the first element in the array.

Sort the rest of the array.

The basic idea for recursively finding the smallest element in an array should be: The smallest element in the array should be the minimum of the first element and the smallest element in the rest of the array. Your program should use no loops, all repetitive actions should be done by recursion. Be sure to demonstrate that all aspects of your program work properly. Here is part of the program to get you started:

#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);

cin>> array[start];

initialize(array, ++ start, end);

}

}

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!