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 geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- C program for Time Complexity plot of Bubble, Insertion and Selection Sort using Gnuplot
- Difference between Binary Heap, Binomial Heap and Fibonacci Heap
- Time Complexity of building a heap
- Heap Sort for decreasing order using min heap
- Time Series Plot or Line plot with Pandas
- Time complexity of insertion sort when there are O(n) inversions?
- An Insertion Sort time complexity question
- Complexity analysis of various operations of Binary Min Heap
- Convert min Heap to max Heap
- Difference between Min Heap and Max Heap
- PyQtGraph - Getting Plot Item from Plot Window
- Can QuickSort be implemented in O(nLogn) worst case time complexity?
- An interesting time complexity question
- Time Complexity where loop variable is incremented by 1, 2, 3, 4 ..
- Time Complexity of a Loop when Loop variable “Expands or Shrinks” exponentially
- Time complexity of recursive Fibonacci program
- Practice Questions on Time Complexity Analysis
- Time Complexity Analysis | Tower Of Hanoi (Recursion)
- Time Complexity of Loop with Powers
- A Time Complexity Question
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