The only application for bubble sort is in the classroom. It's a simple algorithm, arguably the simplest sorting algorithm, and well suited as an introduction to the concept. However, it's hideously inefficient even compared to other quadratic sorting algorithms.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
tungnk1993
Junior Poster in Training
95 posts since May 2010
Reputation Points: 6
Solved Threads: 7
Since bubble sort is efficient
I think you meant to type "inefficient". I also like to add the adverb "woefully" since it drives the point home. ;)
you may want to look into some optimizations of bubble sort; there may serve better purpose
Polish a turd and it's still a turd.Example : Bidirectional bubble sort http://en.wikipedia.org/wiki/Cocktail_sort
Funny you should bring that up, because it has a suitable quote from Knuth:But none of these refinements leads to an algorithm better than straight insertion [that is, insertion sort]; and we already know that straight insertion isn't suitable for large N. [...] In short, the bubble sort seems to have nothing to recommend it, except a catchy name and the fact that it leads to some interesting theoretical problems.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
Insertion sort is also inefficient generally but it still have its own uses :)
tungnk1993
Junior Poster in Training
95 posts since May 2010
Reputation Points: 6
Solved Threads: 7
Insertion sort is also inefficient generally but it still have its own uses :)
I don't think you understand the point that's being made. If you're going to use a quadratic sorting algorithm (bubble sort, insertion sort, selection sort, etc...), bubble sort is the worst choice by a significant margin.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
>>Polish a turd and it's still a turd.
But its a cleaner turd? Anyways, who wants to touch a turd anyways, grosss lol.
As per the application of bubble-sort, the only place I seen it was in my introductory course. But even then I don't know if that is really a good idea. The one time I would show bubble sort is to demonstrate how not to write algorithms, or use it as a leeway to implement a better one.
firstPerson
Senior Poster
3,923 posts since Dec 2008
Reputation Points: 841
Solved Threads: 608