Question: Create a dynamic array of size n and populate it with numbers from 1 to n . Shuffle the numbers in the array. Run the
Create a dynamic array of size n and populate it with numbers from to n
Shuffle the numbers in the array.
Run the selection sort, bubble sort, merge sort, and quick sort on the array to sort the shuffled numbers in increasing order.
Count, for each of the sorting algorithms mentioned above, the number of comparisons and the number of data exchanged in the algorithms.
Repeat steps to for times.
Output the average number of comparisons and the average number of data exchange made for each sorting algorithm.
Define and implement a better algorithm to sort the list based on the data and do steps and for times.
Output the average number of comparisons and the average number of data exchange made for your algorithm.
Your program should start with reading an integer, n from the user.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
