1.

Which of the following sorting algorithms can be used to sort a random linked list with minimum time complexity?(a) Insertion Sort(b) Quick Sort(c) Heap Sort(d) Merge SortI want to ask this question from Singly Linked List Operations in division Abstract Data Types of Data Structures & Algorithms IThis question was posed to me in my homework.

Answer»

The correct option is (d) Merge Sort

Best EXPLANATION: Both Merge sort and Insertion sort can be used for linked lists. The SLOW random-access PERFORMANCE of a linked list makes other algorithms (such as quicksort) perform poorly, and others (such as HEAPSORT) completely impossible. Since worst CASE time complexity of Merge Sort is O(nLogn) and Insertion sort is O(n^2), merge sort is preferred.



Discussion

No Comment Found

Related InterviewSolutions