954,168 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

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
 

Infact there are many sort algorithms, e.g., bubble sort, quick sort, merge sort. And this is bubble sort. In this algorithm there are maximum number of comparison. So use some other algorithm for sorting.
and reply my e-mails :-)

asifdahir
Newbie Poster
1 post since Apr 2005
Reputation Points: 10
Solved Threads: 0
 

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
Team Colleague
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You