In this project, I worked on the implementation and performance comparison of four different sorting algorithms: Selection Sort, Insertion Sort, Bubble Sort, and Merge Sort. The program measures and compares the runtime and memory usage of each algorithm, providing a practical understanding of their efficiency. This project provides a hands-on experience with sorting algorithms, highlighting their runtime and memory usage differences. Through this comparison, you can gain a deeper understanding of the trade-offs involved in choosing a sorting algorithm based on the context of its application.
Selection Sort: A simple sorting algorithm that divides the input list into two parts: the sublist of items already sorted and the sublist of items remaining to be sorted. It selects the smallest element from the unsorted sublist and swaps it with the leftmost unsorted element, moving the sublist boundary one element to the right.
Insertion Sort: Builds the final sorted array one item at a time. It is much less efficient on large lists than more advanced algorithms like quicksort, heapsort, or merge sort.
Bubble Sort: A simple sorting algorithm that repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order. The pass through the list is repeated until the list is sorted.
Merge Sort: An efficient, stable, divide-and-conquer sorting algorithm that divides the input array into two halves, calls itself for the two halves, and then merges the two sorted halves.