Which of the following is correct with regard to insertion sort?

Thu Ha

New member
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-place
 
Answer: a
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.
 

Tìm kiếm

Back
Top