Please enable JavaScript.
Coggle requires JavaScript to display documents.
Searching and Sorting Algorithms (Sorting (Bubble Sort (PROS (it's a…
Searching and Sorting Algorithms
Sorting
Bubble Sort
PROS
it's a simple algorithm that can be easily implemented on a computer
it's an efficient way to check if a list is already in order. For a list of n items you only have to do one pass of n-1 comparisons to check if the list is ordered or not
doesn't use much memory as all the sorting is done using the original list
CONS
it's an inefficient way to sort a list
due to being inefficient, does not cope well with a large list
1) Look at the first two items in the list
2) if they're in the right order, you don't have to do anything
3) if they're in the wrong order, swap them
4) move on to the next pair of items and repeat
5) repeat until you get to the end of the list - this is called one pass
6) repeat until until there are no swaps in a pass
Merge Sort
PROS
more efficient and quicker than bubble sort and insertion sort for large lists
consistent running time
CONS
it's slower than others for small lists
even if the list is already sorted it still goes through the splitting and merging process
uses more memory than the other sorting algorithms
1) splits the original list into two lists
2) carry on splitting until each list only has one item in it
3) merge two lists together and order
4) continue to merge and order lists until the whole list is merged together
Insertion Sort
1) look at the second item in a list
2) compare it to all items before it and insert it into the right place
3) repeat step 2) until the last number in the list has been inserted into the right place
PROS