Most sorting you have seen looks at the data: it compares two numbers, sees which is bigger, and decides what to do next. A sorting network is stranger. It is a fixed wiring diagram of compare-and-swap operations, decided in advance, that never branches on the values it sees.
Picture a few horizontal wires, one per number. Across them sit comparators: each connects two wires and, when a value flows through, it puts the smaller one on the upper wire and the larger on the lower one. Run any input through the same frozen sequence of comparators and it comes out sorted — always, no exceptions, no decisions made along the way.
The remarkable question is not whether such a circuit exists, but how small it can be. What is the fewest comparators that still sorts every input? For most sizes, the honest answer is: nobody knows for sure — the best networks we have were found by enormous computer searches, and proving they are optimal is still open.
Comments
Loading comments...