# Shell Sort Multiple choice Questions and Answers (MCQs)

## Shell Sort Multiple choice Questions and Answers (MCQs)

 Question 1 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Shell sort is also known as .....
 A diminishing decrement sort B diminishing increment sort C partition exchange sort D diminishing insertion sort
Question 1 Explanation:
Shell sort is also known as diminishing increment sort since each pass is defined by an increment h such that only the records which are h units apart will be sorted.

 Question 2 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Statement 1: Shell sort is a stable sorting algorithm.

Statement 2: Shell sort is an in-place sorting algorithm.

 A Both statements are true B Statement 2 is true but statement 1 is false C Statement 2 is false but statement 1 is true D Both statements are false
Question 2 Explanation:
In Shell sort, the relative order of elements with equal values may change. Therefore, it is not a stable sorting algorithm. Shell sort is an in-place sorting algorithm as it requires O(1) auxiliary space.

 Question 3 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Shell sort is applied on the elements 27 59 49 37 15 90 81 39 and the chosen decreasing sequence of increments is (5, 3, 1). The result after the first iteration will be
 A 27 59 49 37 15 90 81 39 B 27 59 37 49 15 90 81 39 C 27 59 39 37 15 90 81 49 D 15 59 49 37 27 90 81 39
Question 3 Explanation:
Given elements 27 59 49 37 15 90 81 39,

First Iteration (span = 5):

So, the sequence after first iteration will be, 27 59 39 37 15 90 81 49.

 Question 4 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Consider the following code snippet, which implements the Shell sort algorithm.

`shellSort( int elements[],  int num....elements ,  int incrmnts[],  int num....incrmnts) { 	int incr,  j,  k,  span,  y; 	for(incr = 0; incr ;&lt num....incrmnts; incr++) 	{ 		span = incrmnts[incr]; data-structure-questions-answers-shell-sort 		for( j = span; j &lt; num....elements; j++) 		{ 			k = j; 			y = elements[j]; 			while (..... ) 			{ 				elements [ k] = elements[k - span]; 				k = k - span; 			} 			elements[k] = y; 		} 	}`

Which condition will correctly implement the while loop?

 A k >= j && y < elements[k- span] B k >= span || y < elements[k + span] C k >= j || y < elements[k + span] D k >= span && y < elements[k- span]
Question 4 Explanation:
In Shell sort, for increment = h we sort the sub-arrays that start at arbitrary element and include every hth element.

So, if h = 4 the algorithms sorts:

Sub-array formed with elements at positions 1, 5, 9, 13 ... in original array

Sub-array formed with elements at positions 2, 6, 10, 14 ... in original array

Sub-array formed with elements at positions 3, 7, 11, 15 ... in original array

Sub-array formed with elements at positions 4, 8, 12, 16 ... in original array

Therefore, the condition given in option k >= span && y < elements[k- span] will implement while loop correctly.

 Question 5 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Shell sort is an improvement on .....
 A insertion sort B selection sort C binary tree sort D quick sort
Question 5 Explanation:
Shell sort is an improvement on insertion sort that allows the exchange of elements that are far apart. Shell sort algorithm sorts separate sub-arrays of the original input array. These sub-arrays contains every hth element of the original array.

There are 5 questions to complete.