Sorting algorithm

« Back to Glossary Index

History and Classification of Sorting Algorithms
– Sorting problem has attracted research since the beginning of computing
– Betty Holberton worked on early sorting algorithms in the 1950s
– Bubble sort was analyzed in 1956
– Asymptotically optimal algorithms have been known since the mid-20th century
– Timsort, widely used, was introduced in 2002
– Sorting algorithms can be classified by computational complexity
– They can have best, worst, and average case behavior
– Some algorithms are in-place, using minimal memory beyond the items being sorted
– Algorithms can be recursive, non-recursive, or both
– Stability refers to maintaining the relative order of records with equal keys

Comparison-based Sorting Algorithms
– Quicksort: O(n log n) average and best case, O(n^2) worst case, partitioning
– Merge sort: O(n log n) worst case, merging
– Heapsort: O(n log n) worst case, selection
– Timsort: O(n log n) worst case, insertion and merging
– Library sort: O(n log n) worst case, insertion

Non-comparison Sorting Algorithms
– Bucket sort (uniform keys): O(n + k) best and average case, O(n^2 * k) worst case, assumes uniform distribution
– MSD Radix Sort: O(n * (k/d)) best and average case, O(n + 2^d) worst case, stable version uses external array
– Spreadsort: O(n * (k/d) * 2^d) best case, O(n * ((k/s) + d) * 2^d) average case, asymptotic based on assumption
– Burstsort: O(n * (k/d)) best and average case, O(n * (k/d)) worst case, better constant factor for sorting strings
– Flashsort: O(n + r) best case, O(n^2) worst case, requires uniform distribution, in-place version not stable

Analysis of Sorting Algorithms
– Sorting networks have varying time complexity and stability.
– Bitonic sorter has a logarithmic time complexity and can be parallelized.
– Bogosort has an unbounded worst-case time complexity and uses random shuffling.
– Stooge sort has a time complexity of log 3 / log 1.5 and can be made stable.
– Slowsort has a time complexity of log n^(log n) and is a multiply and surrender algorithm.

Popular Sorting Algorithms
– Insertion sort is widely used for small data sets.
– Heapsort, merge sort, and quicksort are commonly used for large data sets.
– Hybrid algorithms combine an efficient algorithm with insertion sort for small lists.
– Timsort and introsort are more sophisticated variants used in specific implementations.
– Distribution sorts like counting sort and radix sort are used for restricted data.

Sorting algorithm (Wikipedia)

In computer science, a sorting algorithm is an algorithm that puts elements of a list into an order. The most frequently used orders are numerical order and lexicographical order, and either ascending or descending. Efficient sorting is important for optimizing the efficiency of other algorithms (such as search and merge algorithms) that require input data to be in sorted lists. Sorting is also often useful for canonicalizing data and for producing human-readable output.

Merge sort

Formally, the output of any sorting algorithm must satisfy two conditions:

  1. The output is in monotonic order (each element is no smaller/larger than the previous element, according to the required order).
  2. The output is a permutation (a reordering, yet retaining all of the original elements) of the input.

For optimum efficiency, the input data should be stored in a data structure which allows random access rather than one that allows only sequential access.

« Back to Glossary Index

Submit your RFP

We can't wait to read about your project. Use the form below to submit your RFP!

Gabrielle Buff
Gabrielle Buff

Just left us a 5 star review

Great customer service and was able to walk us through the various options available to us in a way that made sense. Would definitely recommend!

Stoute Web Solutions has been a valuable resource for our business. Their attention to detail, expertise, and willingness to help at a moment's notice make them an essential support system for us.

Paul and the team are very professional, courteous, and efficient. They always respond immediately even to my minute concerns. Also, their SEO consultation is superb. These are good people!

Paul Stoute & his team are top notch! You will not find a more honest, hard working group whose focus is the success of your business. If you’re ready to work with the best to create the best for your business, go Stoute Web Solutions; you’ll definitely be glad you did!

Wonderful people that understand our needs and make it happen!

Paul is the absolute best! Always there with solutions in high pressure situations. A steady hand; always there when needed; I would recommend Paul to anyone!

Vince Fogliani

The team over at Stoute web solutions set my business up with a fantastic new website, could not be happier

Steve Sacre

If You are looking for Website design & creativity look no further. Paul & his team are the epitome of excellence.Don't take my word just refer to my website ""that Stoute Web Solutions created.This should convince anyone that You have finally found Your perfect fit

Jamie Hill

Paul and the team at Stoute Web are amazing. They are super fast to answer questions. Super easy to work with, and knows their stuff. 10,000 stars.

Paul and the team from Stoute Web solutions are awesome to work with. They're super intuitive on what best suits your needs and the end product is even better. We will be using them exclusively for our web design and hosting.

Dean Eardley

Beautifully functional websites from professional, knowledgeable team.

Along with hosting most of my url's Paul's business has helped me with website development, graphic design and even a really cool back end database app! I highly recommend him as your 360 solution to making your business more visible in today's social media driven marketplace.

I hate dealing with domain/site hosts. After terrible service for over a decade from Dreamhost, I was desperate to find a new one. I was lucky enough to win...

Paul Stoute has been extremely helpful in helping me choose the best package to suite my needs. Any time I had a technical issue he was there to help me through it. Superb customer service at a great value. I would recommend his services to anyone that wants a hassle free and quality experience for their website needs.

Paul is the BEST! I am a current customer and happy to say he has never let me down. Always responds quickly and if he cant fix the issue right away, if available, he provides you a temporary work around while researching the correct fix! Thanks for being an honest and great company!!

Paul Stoute is absolutely wonderful. Paul always responds to my calls and emails right away. He is truly the backbone of my business. From my fantastic website to popping right up on Google when people search for me and designing my business cards, Paul has been there every step of the way. I would recommend this company to anyone.

I can't say enough great things about Green Tie Hosting. Paul was wonderful in helping me get my website up and running quickly. I have stayed with Green...