Do either of the following modifications to the Shellsort routine coded in Figure 7.4 affect the worst-case
Question:
a. Before line 11, subtract one from gap if it is even.
b. Before line 11, add one to gap if it is even.
Transcribed Image Text:
/** * Shellsort, using Shell's (poor) increments. 3 * @param a an array of Comparable items. 4 */ public static
/** * Shellsort, using Shell's (poor) increments. 3 * @param a an array of Comparable items. 4 */ public static > void shellsort( AnyType [] a ) { int j; 10 for( int gap - a.length / 2; gap > 0; gap /- 2 ) for( int i - gap; i < a.length; i++ ) 11 12 AnyType tmp - a[ i ]; for( j - i; j >- gap && 13 14 tmp.compareTo( a[j - gap ] ) < 0; j -- gap ) a[ j] - a[ j - gap 1; a[ j] - tmp; 15 16 17 18 19
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 100% (14 reviews)
a No because it is still possible for consecut...View the full answer
Answered By
Joemar Canciller
I teach mathematics to students because I love to share what I have in this field.
I also want to see the students to love math and be fearless in this field.
I've been tutoring these past 2 years and I would like to continue what I've been doing.
5.00+
1+ Reviews
10+ Question Solved
Related Book For
Data Structures and Algorithm Analysis in Java
ISBN: 978-0132576277
3rd edition
Authors: Mark A. Weiss
Question Posted:
Students also viewed these Computer Sciences questions
-
Make the following modifications to your bannerads.html page so that it rotates the banner ads as opposed to selecting them at random. First, modify the opening BODY tag (line 22) so that it appears...
-
The following routine removes the first half of the list passed as a parameter:
-
a. What is the running time of Shellsort using the two-increment sequence {1, 2}? b. Show that for any N, there exists a three-increment sequence such that Shellsort runs in O(N5/3) time. c. Show...
-
Jerome Neeson is a shareholder in Gourmet Chefs Inc., a company that owns and operates a test kitchen in a large metropolitan area. The company is involved in a number of businesses, including...
-
Damping is negligible for a 0.150-kg object hanging from a light 6.30-N/m spring. A sinusoidal force with an amplitude of 1.70 N drives the system. At what frequency will the force make the object...
-
What are the four basic types of reinforcement? What are the five schedules of reinforcement?
-
From the three rightmost columns in Table 8.7, the weighted scores are summed. The bus terminal area has a low score and can be excluded from further consideration. The other two sites are virtually...
-
Woofer Pet Foods produces a low-calorie dog food for overweight dogs. This product is made from beef products and grain. Each pound of beef costs $0.90, and each pound of grain costs $0.60. A pound...
-
A fan blade increases its speed of rotation from 200 revolutions per minute to 250 revolutions per minute in 1 minute. What is the blade's acceleration in rad/s 2 ?
-
SNC is considering an opportunity to add Atlantic Wellness, a large, successful health food chain as a new corporate customer for its herbal nutraceutical product line. Taking on this customer would...
-
Sort the sequence 3, 1, 4, 1, 5, 9, 2, 6, 5 using insertion sort.
-
Show how heapsort processes the input 142, 543, 123, 65, 453, 879, 572, 434, 111, 242, 811, 102.
-
For Apples current annual report, assume it reports the following for raw materials. Required 1. Compute Apples raw materials inventory turnover ratio for the most recent two years. 2. Is the current...
-
Why is the facilitator in JRP so important?
-
A relationship is a natural business association between entities. What is the relationship between student and teacher? Does it depend on how many classes a student can take or how many classes a...
-
Give an example of a many-to-many relationship. Resolve using an entity or an associative entity. Which did you use? Why?
-
Trevs Gardening Services purchased a trailer on 1 July 2019 for $26 200. It was estimated to have a useful life of 5 years and a residual value at the end of that time of $2800. Required (a) What is...
-
Monthly Foodies Magazines ledger includes the following accounts: Subscription Revenue, Unearned Subscriptions Revenue, Prepaid Insurance, Insurance Expense, Prepaid Rent and Rent Expense. The...
-
Olaf lives in the state of Minnesota. A tornado hit the area and damaged his home and automobile. Applicable information is as follows: Because of the extensive damage caused by the tornado, the...
-
Drainee purchases direct materials each month. Its payment history shows that 65% is paid in the month of purchase with the remaining balance paid the month after purchase. Prepare a cash payment...
-
Professor Armstrong suggests the following procedure for generating a uniform random permutation: PERMUTE-BY-CYCLIC (A) 1 n length [A] 2 offset RANDOM (1, n) 3 for i 1 to n 4 do dest i + offset 5 if...
-
Explain how to implement the algorithm PERMUTE-BY-SORTING to handle the case in which two or more priorities are identical. That is, your algorithm should produce a uniform random permutation, even...
-
What are the minimum and maximum numbers of elements in a heap of height h?
-
The Village of Seaside Pines prepared the following enterprise fund Trial Balance as of December 31, 2020, the last day of its fiscal year. The enterprise fund was established this year through a...
-
In the context of digital transformation and the growing influence of artificial intelligence, what ethical considerations should leaders take into account to ensure that technology is deployed in...
-
How can ethical leadership influence corporate governance structures, and what governance practices or oversight mechanisms can be established to ensure that ethical principles are embedded in...
Study smarter with the SolutionInn App