![]() The idea of Merge Sort is to divide the data-set into smaller data-sets, sort those smaller data-sets and then join them (merge them) together. Merge Sort is considered to be one of the fastest sorting algorithms, it is a bit more complex than Selection and Bubble Sort but its more efficient. ![]() ![]() The worst-case scenario for this algorithm would be if all the elements in the data-set were in reverse order making the algorithm make more “swaps”, but we do see that the best-case scenario is not as bad as Selection Sort because unlike Selection Sort this algorithm is smart enough to realize in its first iteration that the data-set is already sorted. Bubble sort also sorts the lowest elements to be closer to the left because within each iteration the higher value will swap places with the lower value, so it moves lower elements to the left and higher elements to the right. So Selection Sort sorts from the smallest element to the highest and Bubble Sort from highest to lowest. The way this algorithm processes the input is just like a bubble trying to reach out to the surface, within each iteration the algorithm will find the highest value and put it at the end of the data-set or were that value belongs by comparing each pair of elements in the data-set. I would say that Bubble Sort might be the simplest sorting algorithm.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |