ArraysLesson 6Free preview
DSA Selection Sort
This lesson is part of DSA · All levels
Summary
Selection sort works by finding the smallest element on the rest of the list, and then swapping it with the element in the position being processed. Each spin puts one element in its final position, so the number of exchanges is very small. However, the smallest element search is always done fully, so the complexity remains in all cases.
Key points
- Each round selects the smallest element from the rest of the list
- The exchange rate is relatively small compared to the bubble sort
- Depending on the initial order of the data, complexity is always
- It's unstable because the exchange can change the order of elements with the same value
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.