Answered step by step
Verified Expert Solution
Link Copied!

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 1 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 2 to 4 for 100 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 2 and 4 for 100 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

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions