So I have 4 different algorithms to sort numbers that me and my best friends wrote to see who's worked the best. They are not the greatest ..since we aren't the greatest programmers..haha but we thought it'd be fun. I thought I'd let you guys take a look at them if you want! just for fun..haha I've attached them.


ohh and if any of you know anything about asymptotic notation is there any way you could figure what the notation would be for all four algs. attached..? If not thats fine but i'm interested in finding out so when we do compare them it would help. ..p.s. don't laugh to much! I'd really like some feedback on these algs. even though they probably aren't so great!

There's no such thing as a "Best" sorting algorithm. Depending on the amount of data you're holding, and how ordered the data is to start with, one algorithm may be better than the other in different situations.


If you wanted to test them out against each another, you could devise a way profiling them, eg, by measuring the time they each take to sort an array of a million randomly generated numbers, or by sorting some pre-defined sets of data and checking the number of passes.

The results are likely to be inconclusive, since there is no "best" sort algorithm. Have a look at this list of different sort methods - http://en.wikipedia.org/wiki/Sorting_algorithm

>to see who's worked the best.
That's going to be difficult even if you just stick to profiling. Two of the algorithms sort arrays and two of them sort linked lists, so the innate performance will be different even without the sort. A better test would sort only linked lists or only arrays for all of the algorithms.

>They are not the greatest ..since we aren't the greatest programmers..haha
They all seem to be unique creations (or at least somewhat unconventional), so props for that.

>is there any way you could figure what the notation would be for all four algs. attached..?
Why not use this as a chance to learn how to analyze your algorithms? Anyway, this is my initial take on the sorts after a quick glance:

Ron - This is a straightforward technique. Ron is running the linked list through a pre-sort filter that swaps values (only if needed) from the outside in. If a lot of swaps are made this will make the insertion sort step faster, and if a lot of swaps aren't made, the insertion sort would have been fairly quick to begin with. The filter (called a spiral patch) takes linear time and the insertion sort takes quadratic time. The sort as a whole is O(n^2).

Brian - This is really little more than an exceptionally inefficient selection sort. I'd call it O(n^2) + O(k) because both of those factors are equally devastating to the performance of the algorithm. Brian also needs to learn how to comment his code better.

Casey - Like Ron, Casey runs the array through a linear pre-sort filter. Casey then runs the array through a quick and dirty divide and conquer sort (which itself is a recursive linear filter), runs the array through the pre-sort filter again (maybe it should be a function if you use it more than once) and finally finishes off the algorithm with bubble sort. The algorithm as a whole is O(n^2), but the linear filters could make this a pretty zippy sort in practice. I don't think bubble sort was a wise choice for the finalizer.

Paul - Despite the comments, I'd say that this is more of a one step Shell sort than a merge sort variation. It's still O(n^2), but the result is likely to be faster than just running a basic insertion sort on the linked list.

Strictly from an asymptotic perspective, Ron, Casey, and Paul are all equal but Brian falls short. My guess is that Ron will be the most consistent overall, followed by Casey, then Paul, and Brian will still fall short in all of the tests. Casey and Paul will have niche areas that perform better than Ron, but probably not sufficiently better to determine a clear winner across the board.

Take these estimates with a grain of salt. I'm simply going on a 2 or 3 minute judgment of each program, and I didn't run any of them.

Wow thanks for the feedback. We actually are testing these algorithms with samples of 10,100,1000,5000,10000 and 15000 sets of random numbers..except for casey's as it is seeded by a random number generator.