Sorting Algorithms
Choosing Algorithms:
The decision of which algorithms to implement was an interesting one. There are a ton of different sorting algorithms out there, each with their benefits and drawbacks. I decided early on that the first one would be bubble sort. It is very easy to implement and simple to confirm the correct process, which makes potential debugging easier. After deciding on having one sorting algorithm be simple, bad, and rarely used, I wanted to also include an algorithm that was harder, good, and frequently used. This lead me to select both Merge Sort and Quick Sort as potential candidates.
The decision of which algorithms to implement was an interesting one. There are a ton of different sorting algorithms out there, each with their benefits and drawbacks. I decided early on that the first one would be bubble sort. It is very easy to implement and simple to confirm the correct process, which makes potential debugging easier. After deciding on having one sorting algorithm be simple, bad, and rarely used, I wanted to also include an algorithm that was harder, good, and frequently used. This lead me to select both Merge Sort and Quick Sort as potential candidates.
Bubble Sort:
Bubble sort is characterized by being very easy to implement and not very efficient, except for nearly sorted lists. It works by looping through the list n times, where n is the number of items in the list, and comparing side by side values to see if they should be switched, and if so switches them. This gives the algorithm what is known as O(n^2) growth, meaning as the size of the list grows, the time it takes for the algorithm to finish takes the square of that increase more time to finish. This is usually considered pretty bad for algorithms as it causes very large lists to astronomically long amounts of time. Image Credit: wikipedia |
Quick Sort:
Quick sort, as the name suggests, is one of the faster sorting algorithms out there. The order growth of quick sort is O(n*log(n)), which means that the growth rather is much more ideal than bubble sort, especially for very large lists of numbers. It has a couple of variations, but essentially picks a pivot point and moves smaller items below it and larger items above it. It then recursively does this for the other subsections of the list until the full list is sorted. Image credit: wikipedia |