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 | Plot different graphs using plotly and cufflinks
- Heap Sort for decreasing order using min heap
- Queries of nCr%p in O(1) time complexity
- A Time Complexity Question
- Time Complexity of Loop with Powers
- An interesting time complexity question
- Sieve of Eratosthenes in 0(n) time complexity
- Time complexity of all permutations of a string
- Time complexity of recursive Fibonacci program
- Extended Mo's Algorithm with ≈ O(1) time complexity
- Practice Questions on Time Complexity Analysis
- GATE CS 2016 Sec 5 – Time Space 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 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.