Flashsort

Flashsort

Flashsort is a sorting algorithm with extremely good O(n) efficiency for balanced data sets published in 1998 by Karl-Dietrich Neubert.

Algorithm

Flashsort works based on the principle that in either a randomized or partially-ordered data set in which data are in a balanced distribution, one can immediately estimate where an item should be placed when one knows the range of the set. This approximate location is called the "class" of an item A_i, and is computed as

K(A_i) = 1+ extrm{INT}left((m-1)frac{A_i-A_ extrm{min{A_ extrm{max}-A_ extrm{min ight)

which gives a total of m possible classes. After calculating the class of an element, it is inserted into the position in the array given by the order of the class (arranged from 1 through m). The final step is an insertion sort to arrange items in each class and fix any remaining errors [cite journal |last=Neubert |first=Karl-Dietrich |year=1998 |month=February |title=The Flashsort Algorithm |journal=Dr. Dobb's Journal |pages=123 |url=http://www.ddj.com/ |accessdate=2007-11-06] . For implementations of the algorithm, see [cite web |url=http://www.neubert.net/FSOIntro.html |title=The FlashSort Algorithm |accessdate=2007-11-06 |author=Karl-Dietrich Neubert |date=1998] .

Efficiency

In the ideal case of a balanced data set, the efficiency scales as O(n) because each class is similarly sized, creating well-sorted data for the final insertion sort. As an in-place algorithm, it uses minimal memory and it also makes efficient use of the machine cache. In the worst case of unbalanced data, flashsort is as slow as insertion sort, scaling as O(n^2) precisely due to the need to use insertion sort on data that was poorly sorted during classification. Using a faster algorithm such as quicksort in the final step alleviates this problem somewhat, giving an efficiency of O(nlog n) for any randomized data, although the worst case is still O(n^2) [cite web |url=http://jea.acm.org/ARTICLES/Vol5Nbr3/node4.html |title=Cache-Effective Quicksort |accessdate=2007-11-06 |author=Li Xiao, Xiaodong Zhang, Stefan A. Kubricht |work=Improving Memory Performance of Sorting Algorithms |publisher=Department of Computer Science, College of William and Mary, Williamsburg, VA 23187-8795] .

See also

* Big O notation
* Comparison sort
* Computational complexity theory
* List of algorithms

References

External links

* [http://elliottback.com/wp/archives/2006/01/07/sorting-in-linear-time/ Sorting in Linear time]
* [http://citeseer.ist.psu.edu/91922.html Implementations of Randomized Sorting on Large Parallel Machines (1992)]
* [http://stinet.dtic.mil/oai/oai?verb=getRecord&metadataPrefix=html&identifier=ADA253638 Implementation of Parallel Algorithms (1992)]


Wikimedia Foundation. 2010.

Игры ⚽ Поможем решить контрольную работу

Look at other dictionaries:

  • Sorting algorithm — In computer science, a sorting algorithm is an algorithm that puts elements of a list in a certain order. The most used orders are numerical order and lexicographical order. Efficient sorting is important for optimizing the use of other… …   Wikipedia

  • List of algorithms — The following is a list of the algorithms described in Wikipedia. See also the list of data structures, list of algorithm general topics and list of terms relating to algorithms and data structures.If you intend to describe a new algorithm,… …   Wikipedia

  • Merge sort — Example of merge sort sorting a list of random dots. Class Sorting algorithm Data structure Array Worst case performance O(n log n) …   Wikipedia

  • Pigeonhole sort — Class Sorting algorithm Data structure Array Worst case performance O(N + n), where N is the range of key values and n is the input size Worst case space complexity O(N * n) …   Wikipedia

  • Counting sort — In computer science, counting sort is an algorithm for sorting a collection of objects according to keys that are small integers; that is, it is an integer sorting algorithm. It operates by counting the number of objects that have each distinct… …   Wikipedia

  • Bogosort — Class Sorting algorithm Data structure Array Worst case performance [1] Best case performance Ω …   Wikipedia

  • Comb sort — Class Sorting algorithm Data structure Array Worst case performance O(n log n)[1] …   Wikipedia

  • Cocktail sort — Class Sorting algorithm Data structure Array Worst case performance О(n²) Best case performance O(n) …   Wikipedia

  • Topological sorting — Dependency resolution redirects here. For other uses, see Dependency (disambiguation). In computer science, a topological sort or topological ordering of a directed graph is a linear ordering of its vertices such that, for every edge uv, u comes… …   Wikipedia

  • Quicksort — Infobox Algorithm class=Sorting algorithm Quicksort in action on a list of numbers. The horizontal lines are pivot values. data=Varies time=O(nlog n) on average space=Varies by implementation optimal=Sometimes Stability= [Sorting… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”