Can someone please help me out!!
Can someone explain this sort algorithm to me and how i can make a more efficient version, justifying the changes.
for (int p = 0; p a[counter+1])
swap(a, counter, counter+1);
Apreciate all help.
nabil1983
Junior Poster in Training
73 posts since Mar 2005
Reputation Points: 13
Solved Threads: 0
More efficent?
Arrays.sort(ArrayName);
server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20
Depending on the application of your sort, a radix sort might also be considered. Though not the most efficient for smaller arrays, I hear its the fastest for very large arrays. The quick sort works pretty well and fast, and its rather easy to understand so its probably your best bet to look into that.
Phaelax
Practically a Posting Shark
858 posts since Mar 2004
Reputation Points: 92
Solved Threads: 51
Bubble sort is the most inefficent, and I believe that QuickInsertionSort is the most efficent.
server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20
Which sorting algorithm is the most efficient depends on what is being sorted and how random (compared to the sorted state) the initial data is.
jwenting
duckman
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337