Question: 1. Shell Sort (20 points) Consider the following procedure that generates a sequence of integers used by Shell sort to sort n integers, n1. The

 1. Shell Sort (20 points) Consider the following procedure that generates

a sequence of integers used by Shell sort to sort n integers,

1. Shell Sort (20 points) Consider the following procedure that generates a sequence of integers used by Shell sort to sort n integers, n1. The integers generated are stored in the variable gap. Generate-Sequence (n) 01 02 03 04 05 06 07 08 09.while (p >0) 10 k1 while (k 0) 10 k1 /end of while (k - gap and r[i-gaptemp-r) r[i] r[i-gap]; i + i-gap; /* end of while (i >- gap and */ 20 ritemp-r 21 /* end of for j +gap to (n - 1) */ gap + (gap / 3) x2;/* more gaps: integer operations seq.count seq-count - 1; 23 24 25 26 27 while (seq-count 0/end of do/ k k/3 P P - 1; /* integer division/ /* end of while (p0) (e) (7 points) Consider the array r -[20, 19, 18, 17, 16. 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]. The first gap is 9. Show the array r right after 9-sorting. 1. Shell Sort (20 points) Consider the following procedure that generates a sequence of integers used by Shell sort to sort n integers, n1. The integers generated are stored in the variable gap. Generate-Sequence (n) 01 02 03 04 05 06 07 08 09.while (p >0) 10 k1 while (k 0) 10 k1 /end of while (k - gap and r[i-gaptemp-r) r[i] r[i-gap]; i + i-gap; /* end of while (i >- gap and */ 20 ritemp-r 21 /* end of for j +gap to (n - 1) */ gap + (gap / 3) x2;/* more gaps: integer operations seq.count seq-count - 1; 23 24 25 26 27 while (seq-count 0/end of do/ k k/3 P P - 1; /* integer division/ /* end of while (p0) (e) (7 points) Consider the array r -[20, 19, 18, 17, 16. 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]. The first gap is 9. Show the array r right after 9-sorting

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!