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
- 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
- Python | Pandas Dataframe.plot.bar
- Python | Plot different graphs using plotly and cufflinks
- 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
- Practice Questions on Time Complexity Analysis
- Time Complexity where loop variable is incremented by 1, 2, 3, 4 ..
- Time Complexity Analysis | Tower Of Hanoi (Recursion)
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.