1.

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 arrayThe 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

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.



Discussion

No Comment Found

Related InterviewSolutions