Wednesday, April 22, 2020

A simple mistake on sorting

I was watching YouTube channel the other day for CS50 by Harvard. I think the professor slipped and said something about cutting short the bubble sort if the scan did no swap. That is fine on its own. However, he also mentioned something about doing it to the selection sort as well. That is not fine. There are cases where selection sort had no swap on a scan. Come to think of it, there's a popular book that has the same error. Except in that case, it was calling selection sort, a bubble sort.

I think I can do better. Hmmm. Maybe I should!