Skip to content
Related Articles
Open in App
Not now

Related Articles

ISRO | ISRO CS 2018 | Question 17

Improve Article
Save Article
  • Last Updated : 10 Jul, 2018
Improve Article
Save Article

Of the following sorting algorithms, which has a running time that is least dependent on the initial ordering of the input?

(A) Merge Sort
(B) Insertion Sort
(C) Selection Sort
(D) Quick Sort


Answer: (A)

Explanation: 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 the order of input sequence.

So, option (A) is correct.

Quiz of this Question

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!