2️⃣

16.2 Selection Sort - What it Does

Selection Sort - What it Does

Let's talk about what Selection Sort does. You start searching from the first element to find the smallest element. Once you find it, you swap with the first element. Now you start searching from the second element to find the smallest element. Once you find it, you swap with the second element. This process of searching and swapping continues until you start searching from the last element. Now the list of numbers is sorted!
Picture for visualizing Selection Sort:
notion image
Video for visualizing Selection Sort: https://www.youtube.com/watch?v=92BfuxHn2XE
💡
Sorting is not only limited to sorting from least to greatest. However, for the Selection Sort algorithm discussed in this chapter, we are only sorting from least to greatest for simplicity. A small modification can be made to sort by other categories.
 
⚖️
Copyright © 2021 Code 4 Tomorrow. All rights reserved. The code in this course is licensed under the MIT License. If you would like to use content from any of our courses, you must obtain our explicit written permission and provide credit. Please contact classes@code4tomorrow.org for inquiries.