Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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, 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
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started