Consider the quick sort algorithm as implemented in the text using the sort pattern. Which of the following data characteristics give the fastest run time? Explain.

a. An array sorted into increasing values.
b. An array sorted into decreasing values.
c. An array of random values
d. An array that increases for half the array, then decreases

Part c) an array of random values will have the least chance of having the split create consistently equal subarrays, hence give a runtime of O(N log N).
Explanation: All the other choices guarantee split gives subarrays of size 1 and N-1, hence give quadratic performance. Part d) requires a little thought, but it too gives quadratic runtime.

Computer Science & Information Technology

You might also like to view...

When users want to return all results where the text ends with "housing" they can use a criteria of ________

Fill in the blank(s) with correct word

Computer Science & Information Technology

The __________ is the human with overall responsibility for setting the security policy of the organization, and, thus, for decisions about deploying and configuring the IDS

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology