Update
This commit is contained in:
parent
dd3842ae42
commit
cc40dcb437
19 changed files with 1826 additions and 1819 deletions
|
@ -1,10 +1,10 @@
|
|||
# Sorting
|
||||
|
||||
Sorting means rearranging a sequence, such as a [list](list.md) of numbers, so that the elements are put in a specific order (e.g. ascending or descending). In [computer science](compsci.md) sorting is quite a wide topic, there are dozens, maybe hundreds of sorting [algorithms](algorithm.md), each with pros and cons and different attributes are being studied, e.g. the algorithm's [time complexity](time_complexity.md), its stability etc. Sorting algorithms are a favorite subject of programming classes as they provide a good exercise for [programming](programming.md) and analysis of algorithms and can be nicely put on tests :)
|
||||
Sorting denotes the action of rearranging a sequence, such as a [list](list.md) of [numbers](number.md), so that the elements are put in a specific [order](order.md) (e.g. ascending or descending). In [computer science](compsci.md) sorting enjoys the status of a wide and curious topic, there are dozens, maybe hundreds of sorting [algorithms](algorithm.md), each with pros and cons and different attributes are being studied, e.g. the algorithm's [time complexity](time_complexity.md), stability etc. Sorting algorithms are a favorite subject of programming classes as they provide a good exercise for [programming](programming.md) and analysis of algorithms and can be nicely put on tests :) Sorting algorithms are like [Pokemon](pokemon.md) for computer nerds, some are big, some are small and cute and everyone has a favorite. { Gotta implement them all? ~drummyfish }
|
||||
|
||||
Some famous sorting algorithms include [bubble sort](bubble_sort.md) (a simple [KISS](kiss.md) algorithm), [quick](quick_sort.md) and [merge](merge_sort.md) sort (some of the fastest algorithms) and [stupid sort](bogosort.md) (just tries different [permutations](permutation.md) until it hits the jackpot).
|
||||
Some celebrities among sorting algorithms are the [bubble sort](bubble_sort.md) (a simple [KISS](kiss.md) algorithm), [quick sort](quick_sort.md) (a super fast one), [merge sort](merge_sort.md) (also lightning fast) and [stupid sort](bogosort.md) (just tries different [permutations](permutation.md) until it hits the jackpot).
|
||||
|
||||
In practice we often get away with using just some of the simplest sorting algorithms (such as [bubble sort](bubble_sort.md) or [insertion sort](insertion_sort.md)) anyway, unless we're programming a database or otherwise dealing with enormous amounts of data. If we need to sort just a few hundred of items and/or the sorting doesn't occur very often, a simple algorithm does the job well, sometimes even faster due to a potential initial overhead of a very complex algorithm. So always consider the [KISS](kiss.md) approach first.
|
||||
In our day-to-day lives we commonly get away with some of the simplest, uncomplicated sorting algorithms (such as [bubble sort](bubble_sort.md) or [insertion sort](insertion_sort.md)) anyway, unless we're programming a database or otherwise treating enormous amounts of data. If we need to sort just a few hundred of items and/or the sorting doesn't occur very often, a simple algorithm does the job well, sometimes even faster due to a potential initial overhead of a very complex algorithm. So always consider the [KISS](kiss.md) approach first.
|
||||
|
||||
Attributes of sorting algorithms we're generally interested in are the following:
|
||||
|
||||
|
@ -15,7 +15,7 @@ Attributes of sorting algorithms we're generally interested in are the following
|
|||
- **[recursion](recursion.md) and [parallelism](parallel.md)**: Some algorithms are recursive in nature, some are not. Some algorithms can be parallelised e.g. with a [GPU](gpu.md) which will greatly increase their speed.
|
||||
- **other**: There may be other specific, e.g. some algorithms are are slow if sorting an already sorted sequence (which is addressed by *adaptive* sorting), so we may have to also consider the nature of data we'll be sorting. Other times we may be interested e.g. in what machine instructions the algorithm will compile to etc.
|
||||
|
||||
In practice not only the algorithm but also its implementation matters. For example if we have a sequence of very large data structures to sort, we may want to avoid physically rearranging these structures in memory, this could be slow. In such case we may want to use **indirect sorting**: we create an additional list whose elements are indices to the main sequence, and we only sort this list of indices.
|
||||
In practice not only the algorithm but also details of its implementation matters. For instance if we have a sequence of very large data structures to sort, we may want to avoid physically rearranging these structures in memory, this could be slow. In such scenario we may want to use **indirect sorting**: we create an additional list whose elements are indices to the main sequence, and we only sort this list of indices.
|
||||
|
||||
## List Of Sorting Algorithms
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue