+1 vote
in Data Structures & Algorithms II by (110k points)
Which of the following sorting algorithm is best suited if the elements are already sorted?

(a) Heap Sort

(b) Quick Sort

(c) Insertion Sort

(d) Merge Sort

I got this question during an online interview.

I'd like to ask this question from Insertion sort in chapter Sorting of Data Structures & Algorithms II

1 Answer

+1 vote
by (614k points)
selected by
 
Best answer
Right option is (c) Insertion Sort

The best I can explain: The best case running time of the insertion sort is O(n). The best case occurs when the input array is already sorted. As the elements are already sorted, only one comparison is made on each pass, so that the time required is O(n).

Related questions

Welcome to TalkJarvis QnA, a question-answer community website for the people by the people. On TalkJarvis QnA you can ask your doubts, curiosity, questions and whatever going in your mind either related to studies or others. Experts and people from different fields will answer.

Categories

...