Open In App

ISRO | ISRO CS 2018 | Question 17

Like Article
Like
Save
Share
Report

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


Last Updated : 10 Jul, 2018
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads