Question: In C, Sorting! In class we made the selection sort for an array of numbers. You need to include that in this assignment. You need
In C,
Sorting!
In class we made the selection sort for an array of numbers. You need to include that in this assignment.
You need to make the bubble sort work for a similar array. You will need to research how the bubble sort works. Please do not copy an online program, yes, I know they are out there.
Your final program should have at least the following functions: void selectionSort(int arr[], int size); void bubbleSort(int arr[], int size);
(You can have more than these, but these are required!)
The functions do not need to return anything. You will need 2 arrays so you can sort the list 2 ways. Please print your array before and after the sorting. (Make sure you make a COPY of the array BEFORE you sort the list, you won't get full credit if you sort an already sorted list).
Once that's completed, you should modify your program to accept values from a file specified in the commandline that contains my values to be sorted.
Input file example: (the first number is the amount of following values) 10 50 78 83 92 100 0 4 72 3 19
Requirements: - Your program must read input from a file in the proper format, NOT stdin - Your program should accept the filename from the command-line as shown in the example below - Your format must match mine exactly (width of 3 with space for numbers)
Example: ---------------------------------------------------------------------- $ ./a.out infile.txt Before: 50 78 83 92 100 0 4 72 3 19 ** Selection Sort ** After: 0 3 4 19 50 72 78 83 92 100 ** Bubble Sort ** After: 0 3 4 19 50 72 78 83 92 100
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
