| | |
Methods of sorting arrays
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
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.
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.
>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.
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.
•
•
•
•
Four bad sorts:
bubble sort
insertion sort
selection sort
shell sort
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.
~~~~~~~~~~~~~~~~~~
Looking for an exciting graduate degree? Robotics and Intelligent Autonomous Systems (RIAS) at SDSM&T See the program brochure here.
![]() |
Similar Threads
- string-comparison methods and the techniques (Java)
- Arrays (Reading in 10 numbers) (C++)
- cant read in arrays and structs at the same time?? (C++)
- To arrange Array Members in ascending order ! (Java)
- copying large arrays (C++)
- Ordering an array (Java)
- Array Sorting on a User Supplied Element (Java)
- First year assigment on reading file, sorting and outputting invoice (C++)
- Sorting arrays of pointers with function? (C)
Other Threads in the C++ Forum
- Previous Thread: Need code for header and program C++
- Next Thread: AIRPLANE Help!!!
| Thread Tools | Search this Thread |
api array arrays based binary c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game generator givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib linkedlist linker list loop looping loops map math matrix memory multiple news number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg sorting string strings temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






