1.

Which of the following is true?(a) Shell sort’s passes completely sort the elements before going on to the next-smallest gap while Comb sort’s passes do not completely sort the elements(b) Shell sort’s passes do not completely sort the elements before going on to the next-smallest gap like in Comb sort(c) Comb sort’s passes completely sort the elements before going on to the next-smallest gap like in Shell sort(d) Shell sort’s passes do not completely sort the elements before going on to the next-smallest gap while Comb sort’s passes completely sort the elementsThis question was addressed to me in unit test.Origin of the question is Shell sort in division Sorting of Data Structures & Algorithms II

Answer»

The CORRECT CHOICE is (a) Shell sort’s passes completely sort the ELEMENTS before going on to the next-smallest gap while Comb sort’s passes do not completely sort the elements

Explanation: Both Shell sort and Comb sort have repeated sorting passes with DECREASING gaps. Unlike Comb sort, in Shell sort the array is sorted completely in each pass before going on to the next-smallest gap.



Discussion

No Comment Found

Related InterviewSolutions