0% found this document useful (0 votes)
115 views5 pages

Comparison of Algorithms: Name Best Average Worst Memor y Stable Method Other Notes

The document compares various sorting algorithms, listing their best, average, and worst case time complexities, whether they are stable, and the general methods used. It includes both comparison and non-comparison sorting algorithms as well as some impractical algorithms.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
115 views5 pages

Comparison of Algorithms: Name Best Average Worst Memor y Stable Method Other Notes

The document compares various sorting algorithms, listing their best, average, and worst case time complexities, whether they are stable, and the general methods used. It includes both comparison and non-comparison sorting algorithms as well as some impractical algorithms.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 5

Comparison of algorithms

Name Best Comparison sorts Memor Average Worst Stable Method Other notes y Quicksort is usually done in place with O(log(n)) stack space.
[citation needed]

Quicksort

Most implementati ons are unstable, as Depen Partitioni stable inds ng place partitioning is more complex. Nave variants use an O(n) space array to store the partition.
[citation needed]

Merge sort

Depend s; worst Yes case is

Used to sort Merging this table in Firefox [2].

In-place Merge sort

Heapsort Insertion sort Introsort

Implemented in Standard Template Library (STL): [3]; can be Yes Merging implemented as a stable sort based on stable inplace merging: [4] No Selection O(n + d), where d is the Yes Insertion number of inversions No Partitioni Used in SGI

Name

Best

Selection sort

Timsort

Shell sort

Comparison sorts Memor Average Worst Stable Method Other notes y STL ng & implementati Selection ons Stable with O(n) extra space, for example using lists No Selection [5]. Used to sort this table in Safari or other Webkit web browser [6]. comparison s when the Insertion data is Yes & already Merging sorted or reverse sorted. Depends on gap sequence; No Insertion or best known is Exchangi Tiny code ng size When using a selfYes Insertion balancing binary search tree In-place with theoretically No Insertion optimal number of writes Yes Insertion No Insertion Finds all the & longest Selection increasing subsequences within O(n Yes

Bubble sort

Binary tree sort

Cycle sort

Library sort Patience sorting

Name

Best

Smoothsort

Strand sort Tournament sort Cocktail sort Comb sort Gnome sort

Comparison sorts Memor Average Worst Stable Method Other notes y log n) An adaptive sort comparisons No Selection when the data is already sorted, and 0 swaps. Yes Selection Selection Exchangi ng Exchangi Small code No ng size Exchangi Tiny code Yes ng size Randomly permute the No Luck array and check if sorted. Remarkably inefficient No Selection sorting algorithm [7] Yes

Bogosort

Slowsort

Non-comparison sorts Name Best Average Worst Memory n Stable << 2k Yes Yes Yes No Assumes uniform distribution of elements from the Notes

Pigeonhole sort Bucket sort (uniform keys)

Non-comparison sorts Name Best Average Worst Memory n Stable << 2k Notes domain in the array.
[2]

Bucket sort (integer keys)

r is the range of numbers to be Yes Yes sorted. If r = then Avg RT =


[3]

Counting sort LSD Radix Sort

r is the range of numbers to be Yes Yes sorted. If r = then Avg RT =


[2]

Yes

No

[3][2]

MSD Radix Sort MSD Radix Sort

Yes

No

Spreadsort

No

Stable version uses an external array of No size n to hold all of the bins In-Place. k / d No recursion levels, 2d for count array Asymptotics are based on the No assumption that n << 2k, but the algorithm does not require this.

The following table describes some sorting algorithms that are impractical for real-life use due to extremely poor performance or a requirement for specialized hardware. Name Bes Avera Wor Stab Comparis Memory t ge st le on N/A No No Yes Other notes Requires specialized hardware Count is number of flips.

Bead N/A N/A sort Simple pancak e sort Spaghe tti (Poll) sort

Yes

This A linear-time, analog algorithm for sorting a sequence of items, Polling requiring O(n) stack space, and the sort is stable. This requires parallel processors. Spaghetti sort#Analysis

Name

Bes Avera Wor Stab Comparis Memory t ge st le on Yes No

Other notes Requires a custom circuit of size

Sorting networ ks

Additionally, theoretical computer scientists have detailed other sorting algorithms that provide better than

time complexity with additional constraints, including:

Han's algorithm, a deterministic algorithm for sorting keys from a domain of finite size, taking time and space.[4] Thorup's algorithm, a randomized algorithm for sorting keys from a domain of finite size, taking time and space.[5] expected time and

An integer sorting algorithm taking space.[6]

You might also like