From the course: Foundations of Algorithmic Thinking with Python

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Challenge: Selection Sort in Python

Challenge: Selection Sort in Python

(upbeat music) - [Instructor] The challenge for this chapter on brute force algorithms is to implement selection sort in Python. So you need to take everything we learned in the last video about the overall flow of how the algorithm works, and also the sub algorithm of finding a minimum value in a list, and put it all together to implement selection sort. So remember, the basic algorithm is to find the smallest element and exchange it with the element in the first position to find the second smallest element and exchange it with the element in the second position to keep going until the array or the list is sorted. Now, if you check out the code for the chapter, which is branch 0304, you'll find an empty function stub that you can use to implement your solution. So we've got a list of numbers, small list 3, 2, 1, 5, 4, which we've called X's and we print it out and then we perform the search and sort and we print it out…

Contents