###### Asked in Java ProgrammingComputer ProgrammingComputer Science

Java Programming

Computer Programming

Computer Science

# Which is the best sorting method?

## Answer

###### Wiki User

###### July 23, 2009 7:06PM

Quicksort will usually be the best performing sort. However, quicksort has a worst-case time complexity of O(n2), which may not be reasonable in a real world application. Heapsort is often used in place of quicksort in these cases, as it has a worst-case of O(n log n).

The last of the "big three" sorts is mergesort, which excels in a few areas. Mergesort is trivially easy to parallelize, which is increasingly useful as multi-CPU machines become more and more common. Mergesort is also a stable sort, which may or may not be useful for a given application.

## Related Questions

###### Asked in C Programming, Computer Programming

### Which is the best sorting technique and why?

The best sorting technique depends heavily on the number and
type of elements you are sorting, whether or not the list is
partially sorted, if it can be sorted completely in memory or
requires external devices, and so forth.
There is no best sorting technique; it depends on the sort
requirements at the time.

###### Asked in Academic Writing, Computer Programming, Research Papers

### What are factors to consider when choosing sorting method?

There are lots of factors to consider. Some important ones are
what are the best, worst, and average times it will take for the
sorting method to complete given a certain amount of elements to
sort. Also important is how much memory the algorithm will use,
what he distribution of the data it is working on is, and whether
you want the algorithm to ensure that if stopped part way though
sorting that the data is not in a less sorted state than when it
started.

###### Asked in Java Programming, C Programming

### Why quick sort is the best?

Quick Sort is an "average" performing sorting algorithm; there
are better algorithms out there, but it is considered the best of
the "learner's algorithms" (generally implied to be quick sort,
bubble sort, selection sort, and gnome sort). It has a
medium-length average sorting time, which is faster than bubble
sorting and gnome sorting, but also has a medium-length best-case
sorting time, with bubble sorting and gnome sorting beating it
speed-wise. It also has a higher memory overhead than in-place
swapping algorithms such as bubble sort and gnome sort.

###### Asked in C Programming

### What is a bubble sort method?

Bubble sort is a highly inefficient sorting algorithm, often
cited as an example of how not to write an algorithm. Bubble sort
is trivial to implement but has O(n*n) complexity when sorting n
items. While perfectly adequate for small data sets, it is wholly
inappropriate for large sets. Nevertheless, insert sort is, on
average, more efficient for sorting small sets.

Load More