# YOU CAN DOWNLOAD 200+ SUBJECTS PDF BOOK FOR COMPETITIVE EXAMINATIONS

## 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 .....

diminishing decrement sort | |

diminishing increment sort | |

partition exchange sort | |

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.

Both statements are true | |

Statement 2 is true but statement 1 is false | |

Statement 2 is false but statement 1 is true | |

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

27 59 49 37 15 90 81 39 | |

27 59 37 49 15 90 81 39 | |

27 59 39 37 15 90 81 49 | |

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 ;< num....incrmnts; incr++) { span = incrmnts[incr]; data-structure-questions-answers-shell-sort for( j = span; j < 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?

k >= j && y < elements[k- span] | |

k >= span || y < elements[k + span] | |

k >= j || y < elements[k + span] | |

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 .....

insertion sort | |

selection sort | |

binary tree sort | |

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.