Hacker News new | ask | show | jobs
by azertify 18 days ago
Matt Parker has an excellent video on this algorithm which should help illustrate why it's absurd (and not bubble sort): https://www.youtube.com/watch?v=ixXOUeBOPJw
1 comments

Really fun video. There's a small mistake in the pseudocode in the video, where the indices are compared instead of the elements. Regardless, when he goes to demonstrate it he does compare the actual element values.

In that demonstration it seems like you can divide each pass into two parts: where i comes before j, and where i comes after j. It seems that only the pass where i comes after j (which is the first half) actually does something useful, the other half seems to sort it the opposite way, which then gets undone with the possibility to change it back being removed (since "i" has moved on permanently).

I suspect you could leave that second half out without changing the result. But if you only consider that first part (of sorting it "oppositely" to the comparison until the other index), it becomes equivalent to bubble sort.