+1 vote
in Data Structures & Algorithms II by (110k points)
Which of the following examples represent the worst case input for an insertion sort?

(a) array in sorted order

(b) array sorted in reverse order

(c) normal unsorted array

(d) large array

The question was posed to me in my homework.

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
The correct option is (b) array sorted in reverse order

The explanation is: The worst case input for an insertion sort algorithm will be an array sorted in reverse order and its running time is quadratic.

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

...