Sorting Algorithms Interview Table
Sorting Algorithms Interview Table
Name Time Avg Best Case Worst Case Space Stable Technique
Merge Sort O(n log n) O(n log n) O(n log n) O(n) Yes Divide & Conquer &
Comparision-based
Quick Sort O(n log n) O(n log n) O(n²) O(log n) No Divide & Conquer &
Comparision-based
Heap Sort O(n log n) O(n log n) O(n log n) O(1) No Heap-based &
Comparision-based
Which algorithm always takes O(n²) time regardless of input? Selection Sort
Why is Merge sort preferred over Quick Sort for sorting linked lists?
Answer: Merge Sort is preferred for sorting linked lists because its divide-and-conquer approach easily divides the list
into halves and merges them efficiently without requiring random access, which is difficult in linked lists. Quick Sort’s
reliance on random access and potential worst-case time complexity makes it less suitable for linked lists.
Which of these comparison-based sorting algorithms has the lowest upper bound on time complexity?
Merge Sort & Heap Sort guaranteed O(n log n) time in all cases
Built-in Sorting Method of Java : Arrays.sort() & Collections.sort() Uses Which Algorithms?
Primitive Data Type - Dual Pivot sorting Algorithm
Objects(User defined or Collections) - Tim Sorting (Combination of Merge and Insertion Sort)