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...
-
The owner of the Weiner-Meyer meat processing plant wants to determine the best blend of meats to use in the next production run of hamburgers. Three sources of meat can be used. The following table...
-
The system resistance for a pipeline is given by \(\Delta p_{\text {sys }}=2.0 Q^{2}\), where \(\Delta p_{\text {sys }}\) is the pressure rise required of a pump to deliver the flow rate \(Q\)...
-
1. Is the pressure for Richard Branson to change Virgins business strategy coming from the internal or external environment? 2. In order to better compete with its rivals, should Virgin focus on a...
-
Discuss the cultural differences between China and the United States. What would be the biggest adjustments I might need to make if working there as an expatriate? What are the most...
-
Choice $693,000 $116,000 $112,000 $91,000 The following beginning and ending inventory balances apply to Holder Company: Beginning Ending $29,000 $27,000 37,000 25,000 Raw Materials Inventory Work in...
-
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.
-
Economists say that individuals make decisions at the margin. What does this mean?
-
Team and Team Development [ Describe the skills and positions needed for your project. An IT project may need programmers, business analysts, and technical architects, for example. List the number...
-
Provide 10 Known Risks of food festival in Malaysia. Describe briefly of the possible risks that could occur during the execution of the food festival in Malaysia and it should be clear...
-
address the following: Describe any experience with Microsoft PowerPoint, whether in school, on the job, or in your personal life. Explain how mastering Microsoft PowerPoint will impact your ability...
-
alysis Page < > of 10 Generate the problem space matrix B and thus determine the optimal alignment between X and Y. (d) Enumerate all possible topological sorts for the DAG shown below. A B C D 9 E...
-
How will you brand your product? Describe your product - features, application and then benefits from a consumer point of view. What gives your product unique business value that will benefit your...
-
Use the substitution or elimination method to solve each system of equations. Identify any inconsistent systems or systems with infinitely many solutions. If a system has infinitely many solutions,...
-
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?
-
A one cubic foot sample of a borrow-source clay weighed 88 lbs. If the specific gravity of solids was measured as 2.70, and the clay was found to be 10 percent saturated, determine the water content...
-
Evaluate the use of novel catalytic systems, such as structured catalysts, catalytic distillation, and multifunctional catalysts, in achieving process intensification, discussing the effects on...
-
Find the minimum tractive effort required for vehicle to maintain 70mph speed at 5%upgrade through an air density of 0.002045 slug/ft^3. Show all steps and unit conversion please Problem 2:...
Study smarter with the SolutionInn App