Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

uthors of modern software libraries are nice enough to include a sort ( ) function for use in applications. These libraries claim that the sort

uthors of modern software libraries are nice enough to include a sort() function
for use in applications. These libraries claim that the sort functions use an algorithm that is at least
O(n lg(n)) in nature. Lets test this claim by writing a small program.
In your language of choice, use the sort routine provided by the language to sort randomly generated
data sets of 5,10,50,100,500,1000,5000, and 10,000 integers. Since we are looking at average data
set sizes, you will need to sort at least 10 or more random data sets for each data set size.
You should implement an algorithm that looks like this:
Algorithm 3: Test the order of the library sort
Output: A data set of run times for each data set size
for size in [5,10,50,100,500,1000,5000,100000] do
Set totalRunTime 0;
for runNumber in [0.. NumberOfRuns) do
GenerateRandomDataSet (dataSet,size);
Note start time;
Sort (dataSet);
Note end time;
Set elapsed time to difference between end and start times;
Add elapsed time to totalRunTime;
Set averageRunTime = totalRunTime / NumberOfRuns;
The function GenerateRandomDataSet(dataSet, size) needs to generate a random set of integers
of whatever size is passed into the function as an input

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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