The heap sort algorithm begins by converting the list into a heap, then sorting. True or False
Answer : TRUE
The algorithm heap sort is comparison based sorting algorithm. There are two steps in heap sort algorithm :-
(i) We convert the list to heap.
This could be max heap ( for sorting in ascending order ) and min heap ( for sorting in descending order )
(ii) After that the largest element is sorted at the root of heap ( in case of ascending ) and then we replace it by the last item of the heap and reduce the heap size by one. And finally heapfiy the root.
We continue repeating (ii) till the heap size is greater than one.
Thus the answer is TRUE.
Get Answers For Free
Most questions answered within 1 hours.