0

Shell sort or odd-even transposition?

In my tests come Even-odd transposition sort is faster, correct?

3
  • There are already many comparisations of sorting algorithms, for example you can find one here: home.westman.wave.ca/~rhenry/sort Commented Nov 13, 2011 at 11:04
  • For what? For all we know, counting sort could be the best solution here.. more information about what you're sorting would help. Commented Nov 13, 2011 at 12:22
  • -1 for an unclear question. What are you trying to learn by posting this question? As other commenters have noted, comparisons of sorting algorithms are widely available. If your question had been something like the following, you would have more chance of success: "I've been experimenting with shell sort and odd-even sort on XXX kind of data in a YYY data structure. My expectation was that the result would be AAA, but instead it was BBB. I have discounted the possibility that it could be because CCC or DDD. How can this be explained? Commented Nov 18, 2011 at 19:02

6 Answers 6

3

It depends on your data layout.

But QuickSort is a pretty general purpose sorting algorithm if what you are going to sort is not huge. If you are planning to sort huge amounts of data, then you need something with intermediate memory such as MergeSort.

Sign up to request clarification or add additional context in comments.

Comments

1

If I remember correctly, odd-even sort is very similar to bubble sort, but it can be executed in parallel.

On a single CPU core, Shell sort is generally better, but bubble/odd-even may win on small datasets.

Comments

1

In most cases it doesn't make sense to code your own sort algorithm. Nearly every environment has a built-in sort that should be your first choice. Even-odd transposition is O(n^2) for the worst data (on a single core).

Comments

0

Shell sort is faster for large arrays. How large you need to take the array before you see that depends on your implementation of both algorithms.

Comments

0

In most non-trivial case it does make sense to code your own sorting algorithm, but not all cases are non-trivial. It all depends on what you know about the data being sorted. There are even cases where bubblesort is a valid choice (or maybe even optimal).

1 Comment

I respect your contrarian point of view. Its pretty easy to code mylist.sort() in C++ with STL. And efficient too.
0

Shell sort may be implemented with many variants of a initial gap size and its decrement in every step. The original algorithm is O(n^{3/2}), but some improvements were presented by Hilberd, Sedgewick and Ciura. So if you are asking which is better, you must always say which implementation do you use. So a single core shell sort should win on every sufficiently large dataset. On multiple cores will probably win odd-even sort, because it can use more processing units.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.