1.

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 falseThe question was posed to me in unit test.This is a very interesting question from Shell sort in portion Sorting of Data Structures & Algorithms II

Answer»

The correct option is (b) Statement 2 is true but statement 1 is false

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



Discussion

No Comment Found

Related InterviewSolutions