Summary
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. We take an element from the unsorted subsequence and put it in the sorted subsequence, while maintaining the order of the elements.
Divide and conquer is the most celebrated technique for problem solving. It has been used in sorting algorithms...