Multiple choices questions in DSA, Interview questions in DSA, Data Structures and Algorithms solved questions, Which sorting algorithm is best? Why heap sort is comparatively best algorithm if memory is the major concern? How much auxiliary spaces need for bubble sort, heap sort and insertion sort? Why merge sort is not a best option if memory is a major concern?
DSA solved MCQ - Which sorting technique is best in terms of time complexity and auxiliary space used?
Next > |
Answer: (b) Heap
sort Among
the given sorting algorithms, heap sort is the best option if memory is a
real concern for you. Heap
sort uses O(1) auxiliary space (i.e., constant) since it is an in-place
sorting algorithm. Also, the worst case running complexity is O(n log n). With
a small worst-case running time and efficient space usage, heap sort is the
best option among the others. On
the other hand, merge sort takes up O(n) auxiliary space. Though the
auxiliary space requirement for both bubble and insertion sort are constant
(O(1)), the worst case time complexity
is O(n2) for both the algorithms.
|
Next > |
No comments:
Post a Comment