1.

Which of the following is correct with regard to insertion sort?(a) insertion sort is stable and it sorts In-place(b) insertion sort is unstable and it sorts In-place(c) insertion sort is stable and it does not sort In-place(d) insertion sort is unstable and it does not sort In-placeI had been asked this question in an interview for internship.My question is taken from Insertion sort in division Sorting of Data Structures & Algorithms II

Answer»

The CORRECT option is (a) insertion sort is stable and it sorts In-place

Easiest EXPLANATION - During insertion sort, the relative ORDER of elements is not changed. Therefore, it is a stable SORTING algorithm. And insertion sort requires only O(1) of ADDITIONAL memory space. Therefore, it sorts In-place.



Discussion

No Comment Found

Related InterviewSolutions