We have already seen how the algorithm for bubble sort works. This is a very basic sorting algorithm. It does the job. One question a computer science student should always ask is "does the algorithm do its job as efficiently as it can?". The answer for bubble sort is no. There are a number of other sorting algorithms which can be used.

We have looked at insertion sort already. This is another way of sorting and also it is a much different way. So why would you choose insertion sort over bubble sort? Merge sort is yet another different way of sorting. Why would we choose this type of sort. Finally in this handout we are about to look at quicksort. Again, why should we use quick sort over any other type of sort?

The obvious answer is that some algorithms perform better than others. Quicksort, even just from its name, you can guess is faster than bubble sort. The new question that you should be asking is why. The answer is complex and lies in an area of mathematics called complexity theory. It is not called complexity theory because it is hard to work out, rather that the whole point of it is to figure out just how complex a problem really is.