The three most popular yet underrated algorithms in computer science are Merge Sort, Quick Sort, and Heap sort. Sounds contradiction? how could anything be popular yet underrated? Yes, that’s what I am going to explain. Almost all CS students have studied and learned these three algorithms with Sudo code but hardly few students implement them. This is probably because we take care of algorithms and the running time of these sorting algorithms than implementation, well that’s still fine.

There are tons of materials and references to get into details of description/Sudo code and runtime. Here I’ll focus more on the implementation part and less on the algorithm. And, I’ll be using python for my implementation.

These three algorithms are so powerful and bear several qualities in terms of computation algorithms. They pose the divide and conquer strategies as well as the greedy method.

Let’s implement a Heap Sort algorithm in Python. Note* heap can be min-heap or max-heap. Here, we shall focus on min-heap but works for both except you need to change operator ‘<’ to ‘>’ or vice-versa where necessary.

#sorting-algorithms #algorithms #python

Implementation of Sorting Algorithms in Python
1.25 GEEK