Which of the following is not true about comparison based sorting algo...
Heapsort is a comparison-based sorting algorithm that uses a binary heap data structure. Like mergesort, heapsort has a running time of O ( n log n ) , O(n\log n), O(nlogn), and like insertion sort, heapsort sorts in-place, so no extra space is needed during the sort.
Hence Option (D) is correct
For Detailed theory notes on Sorting Algorithm click on the following link:
View all questions of this test
Which of the following is not true about comparison based sorting algo...
Comparison Based Sorting Algorithms
Comparison based sorting algorithms are those algorithms that sort an array by comparing elements of the array with each other. Some examples of comparison based sorting algorithms are bubble sort, insertion sort, quicksort, mergesort, heap sort, etc.
Time Complexity
The time complexity of a comparison based sorting algorithm is determined by the number of comparisons made during the sorting process. The minimum possible time complexity of a comparison based sorting algorithm is O(nLogn) for a random input array. This is because any algorithm that needs to compare elements to sort them requires at least O(nLogn) comparisons.
Stable Sorting Algorithms
A sorting algorithm is said to be stable if it maintains the relative order of equal elements in the sorted array. In other words, if two elements are equal, then the one that appears first in the input array should also appear first in the output array. Any comparison based sorting algorithm can be made stable by using position as a criteria when two elements are compared. This means that if two elements are equal, the algorithm should choose the one that appears first in the input array.
Non-Comparison Based Sorting Algorithms
Counting Sort is an example of a non-comparison based sorting algorithm. It does not compare elements to sort them; instead, it uses the frequency of elements in the input array to sort them. Counting Sort has a time complexity of O(n+k), where k is the range of elements in the input array.
Heap Sort is a comparison based sorting algorithm that uses a heap data structure to sort elements. It has a time complexity of O(nLogn) and is not a stable sorting algorithm.
Conclusion
In conclusion, the statement that Heap Sort is not a comparison based sorting algorithm is true. It is a comparison based sorting algorithm, but it is not a stable sorting algorithm. Counting Sort is an example of a non-comparison based sorting algorithm that uses the frequency of elements to sort them.
To make sure you are not studying endlessly, EduRev has designed Computer Science Engineering (CSE) study material, with Structured Courses, Videos, & Test Series. Plus get personalized analysis, doubt solving and improvement plans to achieve a great score in Computer Science Engineering (CSE).