|
Add a purely recursive version (call it sortSelection2) of selection sort function to the program (pizza03.cpp) discussed in the class. For the function, include detailed documentation as mentioned in the class, and properly indented source code. Submit the following: § Printed source code of the working program (to get any credit the program has to work) § Printed output § Self-evaluation table
The main driver should be as follows:
void main(void) { srand(time(NULL)); int a[MAX_COUNT], low, high; for (int i=1; i<=10; i++) { int k; buildArray(a, low, high);
displayArray1(a, low, high); k = min1(a, low, high); cout << "minimum is at " << k << ": " << a[k] << endl;
if (isSorted(a, low, high)) cout << "array is sorted\n"; else cout << "array is NOT sorted\n";
sortSelection2(a, low, high);
k = min2(a, low, high); cout << "minimum is at " << k << ": " << a[k] << endl;
cout << "After sort\n"; displayArray2(a, low, high); if (isSorted(a, low, high)) cout << "array is sorted\n"; else cout << "array is NOT sorted\n"; cout << "=================================\n"; } }
The output from the program should be similar to the following:
84 27 44 33 35 58 91 52 72 98 96 22 90 43 25 21 46 77 76 83 minimum is at 15: 21 array is NOT sorted minimum is at 0: 21 After sort 21 22 25 27 33 35 43 44 46 52 58 72 76 77 83 84 90 91 96 98 array is sorted ================================= 58 31 44 70 83 54 27 56 20 13 minimum is at 9: 13 array is NOT sorted minimum is at 0: 13 After sort 13 20 27 31 44 54 56 58 70 83 array is sorted ================================= |