Question: In 1959, the American computer scientist Donald Shell invented a technique that can be used to speed up many different sorting algorithm. For this project,

In 1959, the American computer scientist Donald Shell invented a technique that can be used to speed up many different sorting algorithm. For this  project, you will apply Shell’s
method to insertionsort.

The basis of the technique is to get the items to move in big steps (rather than shifting elements to the next-higher index). These big-step shifts are done early in the algorithm, and they tend to put the array in nearly sorted order. Later in the algorithm, we use smaller steps (all the way down to steps of size 1, just like an ordinary insertionsort). But by the time that the small steps are being taken, the array is nearly sorted, and that’s a situation where insertionsort is efficient.

The choice of the step sizes affects the performance of the algorithm, but one sequence that is empirically good starts at n/2, and each subsequent step size is about the previous size divided by 2.2.

The overall pseudocode is given here:

SS = n/2; while (ss > 0) Do an insertionsort on the elements data[0], data[ss], data[2*ss]... Also do an insertionsort on data[1], data[ss+1], data[2*ss+1]... And on data[2], data[ss+2], data[2*ss+2]... And so on. The last little insertionsort that you do starts at data[ss-1]. ss = round ss/2.2 to nearest integer; }

SS = n/2; while (ss > 0) Do an insertionsort on the elements data[0], data[ss], data[2*ss]... Also do an insertionsort on data[1], data[ss+1], data[2*ss+1]... And on data[2], data[ss+2], data[2*ss+2]... And so on. The last little insertionsort that you do starts at data[ss-1]. ss = round ss/2.2 to nearest integer; }

Step by Step Solution

3.57 Rating (168 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

include using namespace std int shellSortint arr in... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Data Structures and Other Objects Using Java Questions!