Tag Archives: sorting

Sorting methods in Java.

I made this during school and have used it many a times while preparing for an interview or checking my new work in new languages. The class has static methods for all of the classic sorting methods like selection sort, bubble sort, insertion sort, heap sort, merge sort and quick sort. public class Sorts { [...]
Posted in Programming | Also tagged , | Leave a comment

Heap sort in Python.

Here is an example of heapsort in Python. This sorting method happens to be my favorite of the bunch – I like to think that this is the most elegant sorting method, but I’m sure you could argue against me. Edit: I renamed percolateDown to percolateUp because I realized its really more of a “move [...]
Posted in Programming | Also tagged , | Leave a comment

Insertion sort in Python.

I’m losing faith in my programming skills today, so I’ve decided to re-implement sorting functions. Each day I’ll try to decrease the complexity of the algorithms, but, this day being the first, I’ll give you a quadratic insertion sort. This is an insertion sort, right, or is it shell sort? Heh… def insertionSort(arr): for i [...]
Posted in Programming | Also tagged , | Leave a comment