Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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.
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
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started