answersLogoWhite

0


Best Answer

There is no single algorithm that is ideally suited to every type of sort. If all the data will fit into working memory, then you have a choice of algorithms depending on the size of the set, whether the sort should remain stable or not and how much auxiliary memory you wish to utilise. But if data will not fit into working memory all at once, your choice of algorithm is more limited.

Stability relates to elements with equal status. When the sort is stable, equal elements remain in the same order they were originally input while an unstable sort cannot guarantee this. Stable sorts are ideally suited to data that may be sorted by different primary keys, such that the previous sort order is automatically maintained. That is, if data may be sorted by name or by date, sorting by name and then by date keeps the names in the same order (by date). With an unstable sort, even if you keep track of secondary keys there is no guarantee the secondary or tertiary keys will maintain order.

For small sets of data that will easily fit into memory, an insertion sort offers the best performance with minimal auxiliary storage. This is a stable sort that can be done in place.

For larger sets, a quicksort offers the best performance but is unstable. However, stable versions exist at the cost of performance. Since the algorithm divides the set into smaller and smaller unsorted sets (where each set is in the correct order with respect to the other sets), switching to insertion sort to sort the smaller sets improves overall performance.

For disk-based sorting, merge sort is generally the most efficient. It utilises multiple disks and is stable.

User Avatar

Wiki User

9y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

8y ago

There is no best sorting technique. The main reason we have so many sorting algorithms is that no single algorithm can meet the demands of every data collection. Some algorithms are certainly quicker than others for a given application, but that needn't mean they are the best algorithm for that application. For instance, a slow but stable sort might be preferred over a fast but unstable sort where stability is of greater importance than speed. The medium itself is also a factor. Sorting data in working memory is much easier than sorting data on a mass-storage device because data in memory can generally be sorted in-place, however memory consumption can also be a factor; can we use additional memory to speed up the algorithm? There is no single algorithm that can efficiently cater for every possible case.

When choosing a sorting algorithm, we must consider its complexity (best and worst case), the amount of data involved, the medium, stability, and additional memory considerations. Algorithms that use divide-and-conquer techniques are generally quite fast, but as the divisions become smaller and smaller they become less efficient. Switching to a simpler algorithm to deal with the smaller divisions can help improve efficiency in spite of the increase in complexity, but there will always be fringe cases where even an efficient algorithm will perform badly.

In general (on average), quicksort is the fastest sorting algorithm when the data set is large and memory-based, but it is unstable. Merge sort is stable and ideally suited to large amounts disk-based data. Intro sort is a hybrid algorithm used in many STL implementations, using quicksort before switching to heap sort for the smaller divisions. Timsort is another hybrid, commonly found in Java implementations, which makes use of insertion sort to create minimum runs of data which can then be merged together.

At the other end of the scale are sorting algorithms that have no practical applications beyond academic interest. Bubblesort, for instance, is regarded as a lesson in how not to write an algorithm, as the only case where it actually outperforms any other sorting algorithm is when the data is already sorted, which can be achieved with a single pass of the data. Then there are algorithms that are mere gimmicks, such as Bozo sort which is as efficient as repeatedly shuffling a deck of cards in the hope that one day they'll all land in the correct order.

This answer is:
User Avatar

User Avatar

Wiki User

8y ago

There is no best algorithm. That is; an algorithm optimised to sort billions of elements cannot be compared to an algorithm optimised to sort a handful of elements and an algorithm optimised to sort data in memory may not be quite so efficient when sorting disk-based data.

When comparing algorithms we need to consider a number of factors, including the big-O (best case, worst case, average case), memory consumption, stability, parallel-ability as well as the amount of data being sorted and whether that data is memory-based or disk-based. Even when we arrive at "the best" algorithm for a particular situation, there is no guarantee that it will always perform better than another algorithm. For general purpose memory sorting, adaptive algorithms are generally better than static algorithms. For instance, while quicksort is generally quite fast, when a partition is small enough, switching to a more optimal algorithm better suited to sorting smaller sets, such as insert sort, can improve performance. However, quicksort is unstable and that alone may be a factor that precludes it as an option.

Wikipedia's "sorting algorithm" page gives a useful list of algorithms, comparing their relative complexities and attributes. However, this is merely a guide; only practical tests will determine if an algorithm is suited to the type of data being sorted but general purpose sorting always necessitates some compromise.

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

insertion,bubble,quick, quick3, merge, shell,heap, selection sorting

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

It all depends on your program. If you have a short program, a bubble sort would be suitable, while with larger programs a heap or merge sort is suitable.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

quick sort

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

Quick Sort

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Which of the fastest sorting algorithm?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How many Types of sorting algorithm?

ten types of soting algorithm


In a sorting algorithm the sort order can be changed by changing the operator?

In a sorting algorithm the sort order can be changed by changing the comparison operator.


What is a stock sorting algorithm?

Stock sorting algorithm is a algorithm which is used to sort any kind of stock i.e. any data type containing the primitive values like array ,link list ,stack etc.


What is stock sorting algorithm?

Stock sorting algorithm is a algorithm which is used to sort any kind of stock i.e. any data type containing the primitive values like array ,link list ,stack etc.


How do you sort an array of numbers?

Use a sorting algorithm. There are a bewildering number of sorting algorithms, both stable and unstable. To sort numbers, an unstable sort suffices. The algorithm you use will depend on how many numbers need to be sorted (a small or a large set), however a hybrid algorithm (a combination of two or more algorithms) can cater for both. Introsort (unstable) and timsort (stable) are the two most common hybrid sorting algorithms.


When given a list of numbers what are the steps to put them greatest to least?

There are several different algorithms for sorting numbers by size. ?The steps to take will depend on which algorithm you wish to use.There are several different algorithms for sorting numbers by size. ?The steps to take will depend on which algorithm you wish to use.There are several different algorithms for sorting numbers by size. ?The steps to take will depend on which algorithm you wish to use.There are several different algorithms for sorting numbers by size. ?The steps to take will depend on which algorithm you wish to use.


What are the advantages and disadvantages of sorting algorithm?

shell sort merits and demerits


Is an algorithm that puts elements of a list in a certain order?

This is called sorting.


What is sub-algorithm?

It is an algorithm used by another algorithm as part of the second algorithm's operation.As an example, an algorithm for finding the median value in a list of numbers might include sorting the numbers as a sub-algorithm: There are plenty of algorithms for sorting, and the specifics of the sorting does not matter to the "median value" algorithm, only that the numbers are sorted when the sub-algorithm is done.For what an algorithm is, see related link.


Sorting an array of numbers in java?

here you will a good example on java sorting algorithm application http://javacodespot.blogspot.com/2010/08/java-sorting-animations.html http://javacodespot.blogspot.com/


Who introduce selection sorting algorithm?

in selection sorting at first we take first element of the list and start comparing with all the successive element of that list


What are the different types of algorithm?

insertion,bubble,quick, quick3, merge, shell,heap, selection sorting