can somebody tell me what can be the application of bubble what actually application of bubble sorting means is it the usage of bubble sort in different areas.please give me some applications of it..

happygeek commented: keep it organised please - why ask a programming question in the community intros forum? +0

Dani AI

Generated

is right that Bubble Sort’s main value is pedagogical: it is easy to reason about, shows stability and adaptivity (the early-exit swap flag), and has clear invariants. That said, if your instructor asked for “applications,” there are a few defensible, real but narrow cases. Bubble Sort is rarely used in production because it is O(n^2) on average and even other O(n^2) sorts (like insertion) are usually faster. (en.wikipedia.org)

  • Graphics scan conversion: when you scanline-fill polygons, the list of active edges between successive scanlines changes only by local crossings. A single linear pass of adjacent swaps fixes those local inversions cheaply; this is a classic spot where a bubble-like pass is used. (en.wikipedia.org)
  • Bounded passes to place extremes: after k passes, the k largest items are guaranteed to be in their final positions. If you know you only need the max (or top-k) moved to the end, a tiny number of passes can be acceptable. (en.wikipedia.org)
  • Bubble-like behavior on constrained parallel hardware: odd-even transposition sort is essentially a parallel neighbor version of Bubble Sort used on processor arrays with only local left-right communication. If you truly need adjacent compare-exchange with local links, that is the pattern to reach for. (en.wikipedia.org)

For almost any practical sort of small or nearly sorted arrays, prefer insertion sort: it is simple, stable, typically faster than Bubble Sort in practice, and is widely used as the base case inside faster hybrids. ’s instinct to “optimize” Bubble Sort is understandable, but bidirectional passes still leave you with quadratic behavior; switching to insertion sort (or a modern O(n log n) sort) is the real win. (en.wikipedia.org)

Recommended Answers

All 7 Replies

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.

Since bubble sort is efficient, you may want to look into some optimizations of bubble sort; there may serve better purpose

Example : Bidirectional bubble sort http://en.wikipedia.org/wiki/Cocktail_sort

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.

Insertion sort is also inefficient generally but it still have its own uses :)

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.

>>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.

thanks everyone,i really got what i was looking for :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.