
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
![Shell sort is an in-place comparison-based sorting algorithm which is based on insertion sort algorithm.
It works as follow :
It breaks the original list into a number of smaller sublists, each of which is sorted using an insertion sort. The
unique way that these sublists are chosen is the key to the shell sort. Instead of breaking the list into sublists of
contiguous items, the shell sort uses an increment i, sometimes called the gap, to create a sublist by choosing
all items that are i items apart.
n
a) We say that the our initial gap is floor:
when we divide our sequence into
2k
n
sublists where
2k
k>0 be the number of passes that can be increment until the denominator not greater than n,
n
and then sorting the elements which are
position away with insertion sort. We have three
2k
passes for an array size of 8 to 15.
Demonstrate the Shell algorithm on the input array A = [35,33,42,10,14,19,27,44] showing how even-
%3D
п
tually the algorithm outputs the sorted array [10,14,19,27,33,35,42,44] with initial
gap
2k*
Clearly show
all of your steps.](https://content.bartleby.com/qna-images/question/8552b95a-ccec-4e92-ac6b-3c3a99a88e41/8b745ab9-4b7d-4733-be4a-17cea9cf442a/g08npt5_thumbnail.png)
Transcribed Image Text:Shell sort is an in-place comparison-based sorting algorithm which is based on insertion sort algorithm.
It works as follow :
It breaks the original list into a number of smaller sublists, each of which is sorted using an insertion sort. The
unique way that these sublists are chosen is the key to the shell sort. Instead of breaking the list into sublists of
contiguous items, the shell sort uses an increment i, sometimes called the gap, to create a sublist by choosing
all items that are i items apart.
n
a) We say that the our initial gap is floor:
when we divide our sequence into
2k
n
sublists where
2k
k>0 be the number of passes that can be increment until the denominator not greater than n,
n
and then sorting the elements which are
position away with insertion sort. We have three
2k
passes for an array size of 8 to 15.
Demonstrate the Shell algorithm on the input array A = [35,33,42,10,14,19,27,44] showing how even-
%3D
п
tually the algorithm outputs the sorted array [10,14,19,27,33,35,42,44] with initial
gap
2k*
Clearly show
all of your steps.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 2 steps with 1 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Trace the passes of insertion sort on the following lists:i) {H, K, M, N, P} ii) {P, N, M, K, H}Compare their performance in terms of the comparisons made.arrow_forwardTrace the passes of insertion sort on the following lists:i) {H, K, M, N, P} ii) {P, N, M, K, H}Compare their performance in terms of the comparisons made.arrow_forwardint [] list = {18,57,8,89,7} and the length = 5 Sort the array using insertion sort algorithm. Fill out the trace table public class InsertionSort { /** The method for sorting the numbers */ public static void insertionSort(int[] list) { for (int i = 1; i < list.length; i++) { /** insert list[i] into a sorted sublist list[0..i-1] so that list[0..i] is sorted. */ int currentElement = list[i]; int k; for (k = i - 1; k >= 0 && list[k] > currentElement; k--) { list[k + 1] = list[k]; } // Insert the current element into list[k+1] list[k + 1] = currentElement; } } /** A test method */ public static void main(String[] args) { int[] list = {18,57,8,89,7}; insertionSort(list); for (int i = 0; i < list.length; i++) System.out.print(list[i] + " "); } }arrow_forward
- The bubble sort algorithm discussed in class is used to sort the following sequence of integers: 2 16 38 9 4 14 How many passes must the algorithm perform to guarantee the entire sequence is sorted? What is the list obtained after the first pass? What is the list obtained after the third pass? What is the list obtained after the final pass?arrow_forwardThe best case behaviour occurs for quick sort when the partition function splits the sequence of size n into subarrays of size: Select one: a.n/4 : 3n/4 b.n/4 : 3n/2 c.3n/8 : (5n/8) d.n/2 : (n/2)-1 e.n/2 : n/3arrow_forwardBinary search can only be performed on a/an ………… Sorted array/list Random array/list Any array/list Disordered array/listarrow_forward
- Write the state of the elements of the vector below after each of the first 4 passes of the outermost loop of the insertion sort algorithm. (After the first pass, 2 elements should be sorted. After the second pass, 3 elements should be sorted. And so on.) // index 0 1 2 3 4 5 6 7 vector<int> numbers{29, 17, 3, 94, 46, 8, -4, 12}; insertionSort(numbers); NOTE: Write your answer inside curly braces with numbers separated by commas {29, 17, 3, 94, 46, 8, -4, 12} after pass 1 after pass 2 after pass 3 after pass 4arrow_forwardc++arrow_forwardQuicksort is a powerful divide-and-conquer sorting algorithm that can be described in just four lines ofpseudocode. The key to Quicksort is the PARTITION(A, p, r) procedure, which inputs elementsptorof array A,and chooses the final element x = A[r] as the pivot element. The output is an array where all elementsto the left ofxare less thanx, and all elements to the right of x are greater than x. In this question, we will use the Lomuto Partition Method from class and assume that the pivot isalwaysthe last (right-most) element of the input array. Question: Let A be an array withn= 2k−1 elements, where k is some positive integer. Determine a formula (in terms of n) for the minimum possible number of total comparisons required by Quicksort, as well as a formula for the maximum possible number of total comparisons required by Quicksort. Use your formulas to show that the running time of Quicksort is O(nlogn) in the best case and O(n2) in the worst case.arrow_forward
- Assume that we have a sorted list in an array: Index: 0 1 2 3 4 5 6 7 8 9 10 11 numbers: 12 15 17 19 22 26 28 30 32 34 36 38 we want to use the binary search algorithm to find the value 19 in the list. What would be the indexes of the array that the binary search would check to find the value 19 the indexes and not the actual numbers in the list otherwisearrow_forward3. Given the following list: 9 4 2 6 7 5 3 8 Identify the state of the list while being sorted using the selection sort algorithm.arrow_forwardSelect all the statements that are false, bubble sort is defined below:* Quicksort is the fastest sorting algorithm If you are lucky, you can get O(n) time complexity in Mergesort On the worst case, Bubble sort will give you O(n logn) time complexity Average time complexity of insertion sort is much better than bubble sort Selection sort has the worst space complexity among all the sorting algorithmarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education