Sorting Networks

Starting from the left, a sorting network does a sequence of comparisons, interchanging elements if they are out of order. The network is set up so that by the time the data reaches the right-hand end, all the elements are sorted. Notice that better sorting networks tend to look more complex.

THINGS TO TRY

SNAPSHOTS

  • [Snapshot]
  • [Snapshot]
  • [Snapshot]
  • [Snapshot]
  • [Snapshot]
  • [Snapshot]
  • [Snapshot]
  • [Snapshot]
  • [Snapshot]

DETAILS

Not all types of sorting networks exist for every number of elements. Optimal networks are not yet known for more than 16 elements.
For less than 9 elements, there are no unique optimal sorting networks. Here the Batcher method achieves the minimal number of comparators for each case.
    • Share:

Embed Interactive Demonstration New!

Just copy and paste this snippet of JavaScript code into your website or blog to put the live Demonstration on your site. More details »

Files require Wolfram CDF Player or Mathematica.