Of the following sort algorithms, which has execution time that is least dependent on initial ordering of the input ?
(A) Insertion sort
(B) Quick sort
(C) Merge sort
(D) Selection sort
Answer: (C)
Explanation:
- Insertion Sort gives best case if initial input is already sorted.
- Quick Sort gives worst case if initial input is already sorted.
- Selection Sort gives least number of swaps if initial input is already sorted.
- Merge sort never depend on its initial order of input, does not matter what is input, it always takes O(n log n) time.
So, option (C) is correct.
Quiz of this Question
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
10 May, 2020
Like Article
Save Article