Posts

Showing posts from October, 2012

Half-sort

Half-sort is a sorting algorithm. A copy of it can be found here: https://www.box.com/s/p0pn15736599bv8rb8rx It has the following features: It is an in-place sort. (No extra data space needed.) It works by "divide and conquer" recursion. (It is quite like Quick-sort and Merge-sort.) It is not stable. (i.e. It does NOT keep the original order of identically valued items in the list.) Here is some pseudo-code that explains how the Half-sort algorithm works: Calculate M to be a value that is half way between the smallest item and the biggest item in the collection. You may have to scan the entire collection to find this value, but it may already be known or can be easily calculated. L begins by pointing to the start of the collection and moves forwards until an item bigger than M has been found. R begins by pointing to the end of the collection and moves backwards until an item smaller than M is found. Swap the items at L and R. Carry on doing ...