Continuing the Python algorithm series with Selection Sort. Check out the full playlist here:
• Bubble Sort Algorithm ...
The Selection Sort Algorithm starts by setting the first item in an unsorted list as the position with the lowest (minimum) value. We then use this to compare each of the items to the right. Whenever we find a new item with a lower value, that becomes our new minimum value and we continue on.
After one iteration of the selection sort algorithm, we create two sublists. One will be for unsorted items and the other will be for sorted ones. We move the minimum item from the unsorted sublist into the last position of our sorted sublist.
After we finish all the iterations, we should be left with only the largest number in our unsorted sublist (which is now sorted to the highest position as it is the highest value.)
The selection sort algorithm has a complexity of O(n^2) still but nearly always outperforms the bubble sort algorithm in situations where writing is important (fewer switches, more efficient per iteration).
If you had any questions about the selection sort algorithm, or any of the other algorithms in this series - please let me know in the comments below!
Join The Socials
FB - / codewithderrick
Insta - / codewithderrick
Twitter - / codewithderrick
LinkedIn - / derricksherrill
GitHub - github.com/Der...
Thanks so much for all the support! 5390+ subscribers at the time of writing. Super awesome. I still get so hyped that I get more than 4 views on a new upload. So thankful for you all. I appreciate all the kind words, comments, and support.
#Python #Algorithm #SelectionSort
*****************************************************************
Full code from the video:
def selection_sort(list_a):
indexing_length = range(0, len(list_a)-1)
for i in indexing_length:
min_value = i
for j in range(i+1, len(list_a)):
if list_a[j] #less than list_a[min_value]: #"angled brackets not allowed in youtube description"
min_value = j
if min_value != i:
list_a[min_value], list_a[i] = list_a[i], list_a[min_value]
return list_a
print(selection_sort([7,8,9,8,7,6,5,6,7,8,9,0]))
github.com/Der...
Packages (& Versions) used in this video:
Python 3.7
Atom Text Editor
*****************************************************************
Code from this tutorial and all my others can be found on my GitHub:
github.com/Der...
Check out my website:
www.derrickshe...
If you liked the video - please hit the like button. It means more than you know. Thanks for watching and thank you for all your support!!
--- Channel FAQ --
What text editor do you use?
Atom - atom.io/
What Equipment do you use to film videos?
Blue Yeti Microphone - amzn.to/2PcNj5d
Mic sound shield - amzn.to/3bVNkEt
Soundfoam - amzn.to/37NV9ci
Camera desk stand - amzn.to/3bX8xhm
Box Lights - amzn.to/2PanL95
Side Lights - amzn.to/37KSNut
Green Screen - amzn.to/37SFFnc
What computer do you use/desk setup?
Film on imac (4k screen) - amzn.to/37SEu7g
Work on Macbook Pro - amzn.to/2HJ5b3G
Video Storage - amzn.to/2Pey8sw
Mouse - amzn.to/2PhCtv3
Desk - amzn.to/37O1Mv1
Chair - amzn.to/2uqHE4E
What editing software do you use?
Adobe CC - www.adobe.com/...
Premiere Pro for video editing
Photoshop for images
After Effects for animations
Do I have any courses available?
Yes & always working on more!
www.udemy.com/...
Where do I get my music?
I get all my music from the copyright free RU-vid audio library
www.youtube.co...
Let me know if there's anything else you want answered!
-------------------------
Always looking for suggestions on what video to make next -- leave me a comment with your project! Happy Coding!
14 авг 2024