Write a program that sorts a 50-element array using the selectionsort, the bubbl
ID: 3619130 • Letter: W
Question
Write a program that sorts a 50-element array using the selectionsort, the bubble sort, and the insertion sort. Each sort is to beexecuted twice.a) For the first sort, fill the array with random numbers between 1and 1000.
b) For the second sort, fill the array with a nearly ordered list.Create the nearly ordered list by filling the array with sequentialnumbers and then subtracting 5 from every 10th number in thearray.
c) Each sort (selection, bubble, insertion) is to sort the samedata. For each sort, count the number of comparisons and movesnecessary to order the list.
d) After each sort execution, print the unsorted data following bythe sort data in 5-by-10 matrixes (5 rows of 10 numbers each).After the sorted data, print the number of comparisons and movesnecessary to order the data. Provide appropriate headings for eachprintout.
e) To make sure your statistics are as accurate as possible, youmust analyze each loop limit condition test and each selectionstatement in your sort functions. The best way to count them iswith a comma expression, as shown below. Use similar code for theselection statements.
while((count++, a) && (count++, b))
Explanation / Answer
please rate - thanks sorry I don't understand e--any problems get back to me #include #include void selection(int[],int); void bubble(int [],int); void insertion(int [],int); int fm(int[],int,int,int*); void getarray(int[],int[],int); void printdata(int[],int,int,int,int,char[]); int main() {int i,numbers[50],saved[50],n=50; srand(time(0)); for(i=0;iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.