Answered step by step
Verified Expert Solution
Question
1 Approved Answer
3 sorting means splitting it up into 3 subarrays. Like wise 2 sorting means splitting it up into 2 subarrays (b) (12 points) Assume an
3 sorting means splitting it up into 3 subarrays. Like wise 2 sorting means splitting it up into 2 subarrays
(b) (12 points) Assume an implementation of Shell sort that uses data swaps when it performs k-sorting based on insertion sort. In the worst case, insertion sort requires about m/2 data swaps to sort an array of m elements. Here, we show the coefficient (1/2) of the highest order term (m). Consider a sequence of {1,2,3} for Shell-sorting an array of n elements. We perform 3-sorting, 2-sorting, and 1-sorting successively. What are the number of data swaps required, in terms of n, for (i) 3-sorting, (ii) 2-sorting, and (i) 1-sorting in the worst case? You must provide the highest order term and its coefficient. Justify your answers. For example, you may state how the original array should look like and how that allows you to derive your answer(s). ANS: (i) (ii) (b) (12 points) Assume an implementation of Shell sort that uses data swaps when it performs k-sorting based on insertion sort. In the worst case, insertion sort requires about m/2 data swaps to sort an array of m elements. Here, we show the coefficient (1/2) of the highest order term (m). Consider a sequence of {1,2,3} for Shell-sorting an array of n elements. We perform 3-sorting, 2-sorting, and 1-sorting successively. What are the number of data swaps required, in terms of n, for (i) 3-sorting, (ii) 2-sorting, and (i) 1-sorting in the worst case? You must provide the highest order term and its coefficient. Justify your answers. For example, you may state how the original array should look like and how that allows you to derive your answer(s). ANS: (i) (ii)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored 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