Heap sort explained with simple example
Heap sort is one of the fastest sorting algorithm, which works on Divide and Conquer algorithm. In this sorting algorithm, all the data elements are inserted into a heap (max or min) and then removes item from the root of the heap will give the sorted(descending or ascending) data list.
Pros:
1) Faster algorithm and best performance O(nlogn).
2) Simple implementation.
3) No extra space is needed.
4) Good for cases to find biggest/smallest or top k biggest/smallest element finding kind of scenarios.
Cons:
1) Not a stable sort means position of relative identical data items is not guaranteed.