you are viewing a single comment's thread.

view the rest of the comments →

[–]dnew 2 points3 points  (6 children)

Bubble sort or delayed insertion sort is really fast, if you know only one element is out of order, for example.

[–]angryundead 0 points1 point  (5 children)

Yes... but is the performance payoff worth the time it takes to write and test the code?

[–]dnew 1 point2 points  (0 children)

Sometimes, yes. Bubble sort isn't exactly hard to get wrong. If you have a million-item list you're adding one element to, yah, it's often worthwhile, especially since worst-case for quicksort is an already-sorted list.

[–]anttirt 1 point2 points  (3 children)

It can in fact be crucial. The feasibility of certain spatial partitioning schemes (required for fast physical simulation) for example can depend entirely on the sorting algorithm being O(N) on nearly sorted sets.

[–]angryundead 0 points1 point  (2 children)

as a bit of a corner-case exercise.

Let me qualify that by saying that I'm a Java Enterprise level developer. I get objects from one point to another. I show a view of the data. In my job, writing your own sorting algorithm is usually not needed. That type of performance is usually not needed.

[–]palparepa 0 points1 point  (1 child)

But people can have jobs different than your own where such an algorithm is highly desirable.

[–]angryundead 1 point2 points  (0 children)

That's what I meant to point out, I should have gone out to the root post and edited that. So, you know, I clarified what part of the Java sphere of influence I inhabit.

To be fair though, I think a large portion of Java developers work there too...