This set of Data Structures & Algorithms Multiple Choice Questions & Answers (MCQs) focuses on “Shell Sort
1. Shell sort uses a sequence called a incrementing sequence to sort the elements.
Explanation: Shell sort uses the h1, h2, h3… increment series. As long as h1=1, this sequence will work.
2. Which of the following sorting algorithms is closely related to shell sort?
A) Selection sort
B) Merge sort
C) Insertion sort
D) Bucket sort
Explanation: On hk independent arrays, shell sort performs an insertion sort. It’s essentially an insertion type variant.
3. Why is Shell sort called as a generalization of Insertion sort?
A) Shell sort allows an exchange of far items whereas insertion sort moves elements by one position
B) Improved lower bound analysis
C) Insertion is more efficient than any other algorithms
D) Shell sort performs internal sorting
Explanation: Shell sort is a variation of insertion sort in that it switches elements at a higher rate and over longer distances.
4. Given an array of the following elements 81,94,11,96,12,35,17,95,28,58,41,75,15.
What will be the sorted order after 5-sort?
Explanation: The general strategy for hk sorting is to place the element in the correct spot among I i-hk,i-2hk, etc. for each location, I in hk,, hk+1,…., N-1.
5. Which of the following statements is the basic for loop for a shell sort algorithm?
C) for(i=n/2;i>=0;i- -)
D) for(i=0;i< n;i++;numelements- -)
Explanation: for(increment=N/2;increment>0;increment/=2) represents shell sort, for(i=1;i<n;i++) represents insertion sort, for(i=n/2;i>=0;I- -) represents heap sort, for(i=0;i<n;i++;numelements- -) merge sort.