Misplaced Pages

Pairwise sorting network

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
Pairwise sorting network
Visualization of the Pairwise sorting network with 16 inputsVisualization of the Pairwise sorting network with 16 inputs
ClassSorting algorithm
Data structureArray
Worst-case performance ( log n ) ( log n + 1 ) / 2 {\displaystyle (\log n)(\log n+1)/2} parallel time
Worst-case space complexity n ( log n ) ( log n 1 ) / 4 + n 1 {\displaystyle n(\log n)(\log n-1)/4+n-1} non-parallel time
OptimalNo

The pairwise sorting network is a sorting network discovered and published by Ian Parberry in 1992 in Parallel Processing Letters. The pairwise sorting network has the same size (number of comparators) and depth as the odd–even mergesort network. At the time of publication, the network was one of several known networks with a depth of O ( log 2 n ) {\displaystyle O(\log ^{2}n)} . It requires n ( log n ) ( log n 1 ) / 4 + n 1 {\displaystyle n(\log n)(\log n-1)/4+n-1} comparators and has depth ( log n ) ( log n + 1 ) / 2 {\displaystyle (\log n)(\log n+1)/2} .

The sorting procedure implemented by the network is as follows (guided by the zero-one principle):

  1. Sort consecutive pairwise bits of the input (corresponds to the first layer of the diagram)
  2. Sort all pairs into lexicographic order by recursively sorting all odd bits and even bits separately (corresponds to the next 14 layers of the diagram)
  3. Sort the pairs in nondecreasing order using a specialized network (corresponds to the final layers of the diagram)

Relation to Batcher odd-even mergesort

The pairwise sorting network is very similar to the Batcher odd-even mergesort, but differs in the structure of operations. While Batcher repeatedly divides, sorts and merges increasingly longer subsequences, the pairwise method does all the subdivision first, then does all the merging at the end in the reverse sequence. In certain applications like encoding cardinality constraints, the pairwise sorting network is superior to the Batcher network.

References

  1. Parberry, Ian (1992), "The Pairwise Sorting Network" (PDF), Parallel Processing Letters, 2 (2, 3): 205–211, doi:10.1142/S0129626492000337, S2CID 2986739, archived from the original (PDF) on 2019-10-29
  2. "Sorting Networks".

External links


Sorting algorithms
Theory
Exchange sorts
Selection sorts
Insertion sorts
Merge sorts
Distribution sorts
Concurrent sorts
Hybrid sorts
Other
Impractical sorts


Stub icon

This algorithms or data structures-related article is a stub. You can help Misplaced Pages by expanding it.

Categories: