Question 8Asked in UGC NET Computer Science, December 2014 (Paper II & III, Selected Questions)

You have to sort a list L. consisting of a sorted list followed by a few 'random' elements. Which of the following sorting method would be most suitable for…

You have to sort a list L. consisting of a sorted list followed by a few 'random' elements. Which of the following sorting method would be most suitable for such a task?
  1. ABubble sort
  2. BSelection sort
  3. CQuick sort
  4. DInsertion sort
Show answerHide answer

Correct answer: (D) Insertion sort

Explanation

For a sorted list followed by a few random elements: bubble sort and selection sort take O(n²) time, quick sort degrades to its O(n²) worst case on nearly sorted input, while insertion sort takes close to O(n) time. Hence insertion sort is most suitable.

From UGC NET Computer Science PYQ, December 2014 (Paper II & III, Selected Questions)

This is question 8 of UGC NET Computer Science PYQ, December 2014 (Paper II & III, Selected Questions). See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.