User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 402,755 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,592 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 1114 | Replies: 5
Reply
Join Date: Mar 2005
Posts: 73
Reputation: nabil1983 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
nabil1983 nabil1983 is offline Offline
Junior Poster in Training

Can someone please help me out!!

  #1  
Apr 22nd, 2005
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<n-1; p++)
for (int counter = 0;counter < n-1; counter++)
if (a[counter]> a[counter+1])
swap(a, counter, counter+1);

Apreciate all help.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2004
Location: H4x0rville
Posts: 2,105
Reputation: server_crash is on a distinguished road 
Rep Power: 9
Solved Threads: 18
server_crash's Avatar
server_crash server_crash is offline Offline
Postaholic

Re: Can someone please help me out!!

  #2  
Apr 22nd, 2005
More efficent?

Arrays.sort(ArrayName);
Reply With Quote  
Join Date: Apr 2005
Location: Pakistan
Posts: 1
Reputation: asifdahir is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
asifdahir asifdahir is offline Offline
Newbie Poster

Re: Can someone please help me out!!

  #3  
Apr 22nd, 2005
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 :-)
Reply With Quote  
Join Date: Mar 2004
Posts: 717
Reputation: Phaelax is on a distinguished road 
Rep Power: 6
Solved Threads: 29
Phaelax Phaelax is offline Offline
Master Poster

Re: Can someone please help me out!!

  #4  
Apr 23rd, 2005
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.
Reply With Quote  
Join Date: Jun 2004
Location: H4x0rville
Posts: 2,105
Reputation: server_crash is on a distinguished road 
Rep Power: 9
Solved Threads: 18
server_crash's Avatar
server_crash server_crash is offline Offline
Postaholic

Re: Can someone please help me out!!

  #5  
Apr 24th, 2005
Bubble sort is the most inefficent, and I believe that QuickInsertionSort is the most efficent.
Reply With Quote  
Join Date: Nov 2004
Location: Netherlands
Posts: 5,700
Reputation: jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough 
Rep Power: 18
Solved Threads: 195
Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: Can someone please help me out!!

  #6  
Apr 25th, 2005
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.
42 Private messages asking for help will be ignored
In the frozen land of Nador they were forced to eat Steve's iMinstrels, and there was much rejoicing.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Java Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the Java Forum

All times are GMT -4. The time now is 8:31 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC