Reference no: EM132399137
Make a program that asks the user for the size of an array, then reads a number of integer values (from user input) into the array. No points for that part - it's pretty much the same code as you need for problem (3). Make a function to print out the array and call it to print the array out after all values are read in - basically use your code from question (2), reused. Make a function to implement Insertion Sort and run it on the data array to sort the array (3 pts). Make another function to implement Selection Sort and run it on the data array (3 pts). Print out the array before and after each sort. NOTE: sort the items in DESCENDING ORDER. Biggest first, smallest last. The function prototypes are:
void show_array (int data[ ], int n);
void InsertionSort (int data[ ], int n);
void SelectionSort (int data[ ], int n);
where data[] is the array and n is the size of the array.
If you implement both sort routines you will need to make a copy of the original unsorted array before using the first sort, or else the second sort will be working on a sorted version of the array.
As with all extra credit problems, work on your own. If code is shared between two students, both receive zero points on the problem. If code comes from some other source (the web, for example) that is plagiarism and the student will receive zero points for the whole lab (not just this problem).