Skip to content

Comment on Basic Data Structures and Algorithms in the Linux Kernelparent

Comments

If you already have a list of objects, then bubble sort can beat insertion sort in terms of space, because it doesn't have to construct a second list. That's pretty much the only place left where bubble sort has any advantage, but when you need it, nothing else will do.

Insertion sort does swap elements in place so requires zero additional memory. It is like bubble sort but with better good cases and is as easy to implement. I recommend reading the Wikipedia article about it.

http://en.wikipedia.org/wiki/Insertion_sort

It swaps elements in place in the list it builds, but it requires building another list. Bubble sort doesn't.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.