Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

All together in 1 program with headers and main Sort an array of 10,000 elements using the quick sort algorithm as follows: a. Sort the

All together in 1 program with headers and main

Sort an array of 10,000 elements using the quick sort algorithm as follows:

a. Sort the array using pivot as the middle element of the array.

b. Sort the array using pivot as the median of the first, last, and middle elements of the array.

c. Sort the array using pivot as the middle element of the array. How- ever, when the size of any sublist reduces to less than 20, sort the sublist using an insertion sort.

d. Sort the array using pivot as the median of the first, last, and middle elements of the array. When the size of any sublist reduces to less than 20, sort the sublist using an insertion sort.

e. Calculate and print the CPU time for each of the preceding four steps.

To find the current CPU time, declare a variable, say, x, of type clock_t. The statement x = clock(); stores the current CPU time in x. You can check the CPU time before and after a particular phase of a program. Then, to find the CPU time for that particular phase of the program, subtract the before time from the after time. Moreover, you must include the header file ctime to use the data type clock_t and the function clock. Use a random number generator to initially fill the array.

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

Recommended Textbook for

Introductory Relational Database Design For Business With Microsoft Access

Authors: Jonathan Eckstein, Bonnie R. Schultz

1st Edition

1119329418, 978-1119329411

More Books

Students also viewed these Databases questions

Question

What is an isocost line? An isoprofit line?

Answered: 1 week ago

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago