robert@cs.arizona.edu (Robert J. Drabek) (08/24/90)
Many people saying things like: > > > DON'T use bubble sort; once people learn it, they use it for the > > > rest of their lives, it seems like, and it takes ages to unteach. > > What exactly is wrong with bubble sort? It is the smallest sorting > > algorithm > I agree with Chris, once bubble sort is learned, it is invariably used. > A professor of mine in grad school claimed this was because it had a > nifty name :-). > I would prefer bubble sort was left as an example for an algorithms > course when comparing complexities of common sorts, not introduced > in early language classes. And when discussing sorting algorithms we also need to consider "stability" (records with equal keys don't loose their relative positions). Bubble sort has the advantage of being the simplest stable sort. The Shaker Sort has an even niftier name; it is essentially bubbling towards both ends of the list. It's also stable; has fewer swaps than the Bubble sort; might be an interesting excercise for students to create the Shaker sort after being shown the Bubble sort. -- Robert J. Drabek robert@cs.Arizona.EDU Department of Computer Science uunet!arizona!robert The University of Arizona 602 621 4326 Tucson, AZ 85721