Methods of sorting arrays

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2009
Posts: 4
Reputation: danishamman is an unknown quantity at this point 
Solved Threads: 0
danishamman danishamman is offline Offline
Newbie Poster

Methods of sorting arrays

 
0
  #1
Apr 15th, 2009
Plz provide me complete discription of four algorithms used for sorting arrays e.g bubble sort.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 476
Reputation: nucleon has a spectacular aura about nucleon has a spectacular aura about 
Solved Threads: 91
nucleon's Avatar
nucleon nucleon is offline Offline
Posting Pro in Training

Re: Methods of sorting arrays

 
0
  #2
Apr 15th, 2009
Four bad sorts:
bubble sort
insertion sort
selection sort
shell sort
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 15
Reputation: cause&effect is an unknown quantity at this point 
Solved Threads: 1
cause&effect's Avatar
cause&effect cause&effect is offline Offline
Newbie Poster

Re: Methods of sorting arrays

 
0
  #3
Apr 15th, 2009
The quicksort is a comparison sorting algorithm.

The shell sort is arranging the data sequence in a two-dimensional array and sorting the columns of the array.

The bubble sort algorithm works similar to bubbles finding their own level in water. It compares pair of array elements, moving the larger up.

The shaker algorithm sorts in both directions each pass through the list.
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,730
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 737
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: Methods of sorting arrays

 
1
  #4
Apr 15th, 2009
>Plz provide me complete discription of four algorithms used for sorting arrays e.g bubble sort.
How about you tell us what you came up with first, because this is clearly homework.

>Four bad sorts:
Okay.

>bubble sort
Works for me.

>insertion sort
Insertion sort is not a bad sort. It's a quadratic sort, which means using it on larger lists is a bad idea. However, insertion sort is often the preferred finalizer for the higher performance algorithms. It's also one of the few algorithms that can sort streamed input.

>selection sort
I'll let you keep this one with the caveat that selection sort is good in special cases where data movement is extremely expensive because this algorithm is about as efficient as can be when it comes to copies.

>shell sort
This I disagree with. Shell sort is a mid-range algorithm, where one of the quadratics would be too slow but the overhead of the higher performance algorithms is prohibitive. Keep in mind that before quicksort came around, shell sort was one of the forerunners.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 1,679
Reputation: vmanes is a splendid one to behold vmanes is a splendid one to behold vmanes is a splendid one to behold vmanes is a splendid one to behold vmanes is a splendid one to behold vmanes is a splendid one to behold vmanes is a splendid one to behold 
Solved Threads: 193
vmanes's Avatar
vmanes vmanes is offline Offline
Posting Virtuoso

Re: Methods of sorting arrays

 
0
  #5
Apr 15th, 2009
Originally Posted by nucleon View Post
Four bad sorts:
bubble sort
insertion sort
selection sort
shell sort
I wouldn't call them "bad" sorts - it's all relative. In the days when processor speed was measured in MHz, sure, the first three would seem slow for data sets of any considerable size ( how big a problem do we ever do in an classroom?)

On modern machinery, what once was derided can now be satisfactory, for problems that are larger than we might ever have considered before.

Example - Pentium D, 3.2GHz, list size 10,000 integers.
Bubble sort (done well) takes about 2 seconds
Selection sort - about 1/2 second
Insertion sort - about 1/2 second.

Given that most situations are a sort once, search many times, is that such a huge price to pay? For the student writing the code, the simplicity of these sorts, the ability to easily understand how they function, still has merit.

You want "bad" sorts - look up bozosort or bogosort. Those are bad, really bad.
Everyone's gotta believe in something. I believe I'll have another drink.
~~~~~~~~~~~~~~~~~~
Looking for an exciting graduate degree? Robotics and Intelligent Autonomous Systems (RIAS) at SDSM&T See the program brochure here.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 376
Reputation: Clockowl is on a distinguished road 
Solved Threads: 27
Clockowl's Avatar
Clockowl Clockowl is offline Offline
Posting Whiz

Re: Methods of sorting arrays

 
0
  #6
Apr 15th, 2009
Oh hey look, it's free knowledge!

http://en.wikipedia.org/wiki/Sorting_algorithm
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 476
Reputation: nucleon has a spectacular aura about nucleon has a spectacular aura about 
Solved Threads: 91
nucleon's Avatar
nucleon nucleon is offline Offline
Posting Pro in Training

Re: Methods of sorting arrays

 
0
  #7
Apr 16th, 2009
Excellent info, Narue and vmanes!
(I'm beginning to like being proved wrong.)
And wikipedia does have some decent info, especially the complexity tables.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 1,615
Reputation: jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of 
Solved Threads: 121
jephthah's Avatar
jephthah jephthah is offline Offline
Posting Virtuoso

Re: Methods of sorting arrays

 
0
  #8
Apr 16th, 2009
I'm beginning to like being proved wrong.
Hello, welcome to Daniweb. I'm the head palooka. You can join my club.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC