Books / Sorting Algorithms in Computer Science / Conclusion
Conclusion
Conclusion and Summary
In this book, we reviewed several computer science sorting algorithms, their performance and code examples in different languages. Sorting is the act of rearranging data so that it is in some pre-specified order, such as ascending or descending order. The exact ordering does not really matter, as long as it is a linear, or total ordering, which means that any two elements can be ordered.
Here’s a table comparing performance (time and space complexity in Big O notation) of the sorting algorithms that we studied in this book:
\[\begin{array}{|c|c|c|c|c|} \hline \text { Name } & \text { Best } & \text { Average } & \text { Worst } & \text { Memory } \\ \hline \text { Insertion sort } & n & n^{2} & n^{2} & 1 \\ \hline \text { Selection sort } & n^{2} & n^{2} & n^{2} & 1 \\ \hline \text { Merge sort } & n \log n & n \log n & n \log n & n \\ \hline \text { Heapsort } & n \log n & n \log n & n \log n & 1 \\ \hline \text { Quicksort } & n \log n & n \log n & n^{2} & \log n \\ \hline \text { Shellsort } & n \log n & n^{4 / 3} & n^{3 / 2} & 1 \\ \hline \text { Bubble sort } & n & n^{2} & n^{2} & 1 \\ \hline \end{array}\]We hope you enjoyed this free book from CodeAhoy. Please share it on social media to spread the work and support CodeAhoy.