Selection Sort Flashcards

1
Q

What is selection sort?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the selection sort algorithm?

A
  1. Start with an **unsorted list of size n **
  2. 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does the “find__minimum()” do?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly