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
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- 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
- A Time Complexity Question
- An interesting time complexity question
- Time Complexity of Loop with Powers
- Practice Questions on Time Complexity Analysis
- Time Complexity where loop variable is incremented by 1, 2, 3, 4 ..
- Time complexity of recursive Fibonacci program
- Understanding Time Complexity with Simple Examples
- Time Complexity Analysis | Tower Of Hanoi (Recursion)
- Can QuickSort be implemented in O(nLogn) worst case time complexity?
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.
Improved By : Akanksha_Rai