0% found this document useful (0 votes)
46 views

Time Complexity

The following table describes sorting algorithms that are not comparison sorts. As such, they are not limited by a lower bound. Complexity below are in terms of n, the number of items to be sorted, k, the size of each key, and d, the digit size used by the implementation.

Uploaded by

Shilpa Sd
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views

Time Complexity

The following table describes sorting algorithms that are not comparison sorts. As such, they are not limited by a lower bound. Complexity below are in terms of n, the number of items to be sorted, k, the size of each key, and d, the digit size used by the implementation.

Uploaded by

Shilpa Sd
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

Name Timsort Bubble sort Cocktail sort Comb sort Gnome sort

Average

Worst

Memory Stable Yes Yes Yes No Yes

Selection sort

No

Other notes comparisons Insertion & when the data is Merging already sorted. Exchanging Tiny code Exchanging Exchanging Small code size Exchanging Tiny code size Its stability depends on the implementation. Used to sort this Selection table in Safari or other Webkit web browser [2]. Average case is also Insertion

Method

Insertion sort

Cycle sort Shell sort Binary tree sort Library sort Merge sort

In-place merge sort

, where d is the number of inversions In-place with theoretically No Insertion optimal number of writes No Insertion When using a self-balancing Yes Insertion binary search tree Yes Insertion Used to sort this Depends Yes Merging table in Firefox [3]. Example implementation here: [4]; can be implemented as Depends Merging a stable sort based on stable in-place merging: [5] Yes

Heapsort

No

Selection An adaptive sort - comparisons when the data is Selection already sorted,

Smoothsort

No

Quicksort

and swaps. Can be implemented as a stable sort depending on Depends Partitioning how the pivot is handled. Nave variants use space Used in SGI Hybrid STL implementations Finds all the longest Insertion & increasing Selection subsequences within O(n log n) Selection Selection

Introsort

No

Patience sorting

No

Strand sort Tournament sort

Yes

The following table describes sorting algorithms that are not comparison sorts. As such, they are not limited by a lower bound. Complexities below are in terms of n, the number of items to be sorted, k, the size of each key, and d, the digit size used by the implementation. Many of them are based on the assumption that the key size is large enough that all entries have unique key values, and hence that n << 2k, where << means "much less than." Name Pigeonhole sort Bucket sort Counting sort Average Worst Memory Stable Yes Yes Yes n << 2k Yes Assumes uniform distribution of No elements from the domain in the array. Yes If k = then Avg Notes

RT = LSD Radix Sort MSD Radix Sort MSD Radix Sort Yes No Stable version uses an external array of size No 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.

Yes

No

Spreadsort

No

You might also like