Prerequisite : HeapSort
Heap sort is a comparison based sorting technique based on Binary Heap data structure. It is similar to selection sort where we first find the maximum element and place the maximum element at the end. We repeat the same process for remaining element.
We implement Heap Sort here, call it for different sized random lists, measure time taken for different sizes and generate a plot of input size vs time taken.
Input : Unsorted Lists of Different sizes are Generated Randomly Output : 1000 Elements Sorted by HeapSort in 0.023797415087301488 2000 Elements Sorted by HeapSort in 0.053856713614550245 3000 Elements Sorted by HeapSort in 0.08474737185133563 4000 Elements Sorted by HeapSort in 0.13578669978414837 5000 Elements Sorted by HeapSort in 0.1658182863213824 6000 Elements Sorted by HeapSort in 0.1875901601906662 7000 Elements Sorted by HeapSort in 0.21982946862249264 8000 Elements Sorted by HeapSort in 0.2724293921580738 9000 Elements Sorted by HeapSort in 0.30996323029421546 Complexity PLot for Heap Sort is Given Below
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- C program for Time Complexity plot of Bubble, Insertion and Selection Sort using Gnuplot
- Time Complexity of building a heap
- Time complexity of insertion sort when there are O(n) inversions?
- An Insertion Sort time complexity question
- Python Program for Heap Sort
- Heap Sort for decreasing order using min heap
- Complexity analysis of various operations of Binary Min Heap
- A Time Complexity Question
- An interesting time complexity question
- Time Complexity of Loop with Powers
- Understanding Time Complexity with Simple Examples
- Time complexity of recursive Fibonacci program
- Time Complexity where loop variable is incremented by 1, 2, 3, 4 ..
- Practice Questions on Time Complexity Analysis
- Time Complexity Analysis | Tower Of Hanoi (Recursion)
- Where is Heap Sort used practically?
- C++ Program for Heap Sort
- Can QuickSort be implemented in O(nLogn) worst case time complexity?
- Lexicographical ordering using Heap Sort
- Java Program for Heap Sort
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : Akanksha_Rai