the.bay.news

ICantBelieveItCanSort Sort

programming.dev
ICantBelieveItCanSort Sort
I learned about this from Matt Parker’s Stand-Up Maths [https://www.youtube.com/watch?v=ixXOUeBOPJw] channel. It was originally conceived as a counterexample, a sorting algorithm that was obviously broken, but it does actually sort correctly. The algorithm: for i = 1 to n do for j = 1 to n do if A[i] < A[j] then swap A[i] and A[j] It has a few quirks (like j accessing elements outside of i’s range, and the A[i] < A[j] comparator being backward) that should break it, but they all work together to make the algorithm correctly (if inefficiently) sort the input. paper [https://arxiv.org/pdf/2110.01111] describing the algorithm in more detail.

0 comments

Sign in to join the discussion — your thebay.events account works here.

No comments yet.