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 Sort
Answer: (D)
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.
See following for implementation of merge sort using Linked List.
https://www.geeksforgeeks.org/merge-sort-for-linked-list/
Quiz of this Question
Recommended Posts:
- Introduction to Data Structures | 10 most commonly used Data Structures
- Data Structures | Linked List | Question 1
- Data Structures | Linked List | Question 2
- Data Structures | Linked List | Question 3
- Data Structures | Linked List | Question 5
- Data Structures | Linked List | Question 6
- Data Structures | Linked List | Question 7
- Data Structures | Linked List | Question 8
- Data Structures | Linked List | Question 9
- Data Structures | Linked List | Question 10
- Data Structures | Linked List | Question 11
- Data Structures | Linked List | Question 12
- Data Structures | Linked List | Question 13
- Data Structures | Linked List | Question 14
- Data Structures | Linked List | Question 15
- Data Structures | Linked List | Question 16
- Data Structures | Linked List | Question 17
- Difference between Singly linked list and Doubly linked list
- Generate Linked List consisting of maximum difference of squares of pairs of nodes from given Linked List
- Data Structures | Stack | Question 1

