ISRO | ISRO CS 2018 | Question 17
Of the following sorting algorithms, which has a running time that is least dependent on the initial ordering of the input?
In Insertion sort if the array is already sorted then it takes O(n) and if it is reverse sorted then it takes O(n2) to sort the array. In Quick sort, if the array is already sorted or if it is reverse sorted then it takes O(n2).The best and worst case performance of Selection is O(n2) only. But if the array is already sorted then less swaps take place. In merge sort, time complexity is O(nlogn) for all the cases and performance is affected least on the order of input sequence. So, option (A) is correct.
Quiz of this Question
Please comment below if you find anything wrong in the above post
Please Login to comment...