1.

Which one of the following is false?(a) Heap sort is an in-place algorithm(b) Heap sort has O(nlogn) average case time complexity(c) Heap sort is stable sort(d) Heap sort is a comparison-based sorting algorithmThe question was posed to me during an interview.Question is from Heapsort in section Sorting of Data Structures & Algorithms II

Answer»

Right option is (c) Heap sort is stable sort

Best EXPLANATION: Heap sort is a COMPARISON based sorting algorithm and has time complexity O(nlogn) in the average case. Heap sort is an in-place algorithm as it needs O(1) of AUXILIARY space. Heap sort uses heap and operations on heap can change the relative order of items with the same key VALUES. Therefore, Heap sort is not a stable sort.



Discussion

No Comment Found

Related InterviewSolutions