Selection Sort Flashcards
What is selection sort?
It is a simple and intuitive sorting algorithm
It works by repeatedly finding the minimum element from the unsorted part of the list and placing it at the beginning
Selection sort minimizes the number of swaps required to sort the list It is guaranteed to perform only one swap per pass over any list.
This can be particularly beneficial when the cost of swapping elements is high or involves complex data structures
What is the selection sort algorithm?
- Start with an **unsorted list of size n **
-
Iterate through the list from index 0 to n-1
- find index of the minimum element in the unsorted part
- swap the minimum element w/ the element at the current position
What does the “find__minimum()” do?
This function finds the index of the minimum element in a list starting from a given index
It takes a list and the starting index as parameters
The function iterates through the list, comparing elements and updating the minimum index as needed
It returns the index of the minimum element