Comb Sort

Less known than others presented here sorting algorithms, but quite interesting one for how it pre-processes the data. Comb Sort is basically an improved bubble sort, which allows it to run in O(n log n) time in average cases. Unfortunately, the worst case is still O(n2). The main idea behind the Comb Sort is to … Continue reading Comb Sort

Insertion Sort

Another elementary but interesting sorting algorithm. Its time complexity is O(n2), so every time the size of an array to be sorted is doubled, the efforts quadruple. Insertion sort starts from index 1 by remembering its value and comparing to the value under index 1 - 1. If the value under previous index is less … Continue reading Insertion Sort