Posts Tagged ‘sorting’

Sorting algorithms: Merge sort

The next sorting algorithm in this series is the Merge Sort. Of the algorithms covered so far, this algorithm comes closest to the Shell Sort algorithm. The reason for this lies in how the comparisons are done in both algorithms: instead of working on the entire array, both the shell sort and the merge sort [...]

Read the rest of this entry »

Sorting algorithms: Selection sort

1000 elements to sort. Sanity check. PHP native sort() algorithm took: 0.002461 seconds. Memory used: 48264 bytes Running SelectionSort sort. Algorithm took: 0.273260 seconds. Memory used: 48272 bytes 1000 elements to sort.Sanity check. PHP native sort() algorithm took: 0.002461 seconds. Memory used: 48264 bytesRunning SelectionSort sort. Algorithm took: 0.273260 seconds. Memory used: 48272 bytesNext in [...]

Read the rest of this entry »

Sorting algorithms: Shell sort

Third in the line of posts on sorting algorithms (first was Bubble Sort and the second was Insertion Sort) is the Shell Sort. This is basically a variant of the insertion sort, with the difference that you’re sorting the array multiple times. Another way of looking at this is that the shell sort is really [...]

Read the rest of this entry »