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);
}
}
Your program should use no loops, all repetitive actions should be done by recursion.
Your program should use no loops, all repetitive actions should be done by recursion.
Your program should use no loops, all repetitive actions should be done by recursion. No for loops , no while loops all repetitive actions should be done by recursion
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started