Sorting is used to solve many complex problems. Sorted data aids searching algorithms too. We discussed some very useful sorting algorithms, such as bubble sort, selection sort, insertion sort, merge sort, and quick sort. Every sorting algorithm has its own complexity.
We discussed bubble sort. Bubble sort is one of the earliest developed sorting algorithms. We implemented it in Scala.
After bubble sort, we moved on to selection sort, where in every pass, a small element is selected and put in a sorted list. Here, we found that in every pass, only one exchange is done, but the number of comparisons will be the number of unsorted elements.
The simplicity of insertion sort touched everyone. It uses two subsequences: one sorted and one unsorted. ...