Python Radix Sort Tutorial: Sorting Strings Made Easy

Sdílet
Vložit
  • čas přidán 28. 07. 2024
  • Get ready for an in-depth look at the radix sort algorithm with Rob on Algorithm Monday! In this video, Rob explains radix sort, a non-comparative algorithm, on the board in detail and then code out a solution in Python to sort strings. Follow along as Rob guides you through the step-by-step process of radix sorting a list of names using Python. Don't forget to subscribe to Rob's channel for more algorithm insights and coding tutorials!
    Note: I did not set it up in this video to sort correctly when there is a word that is a substring of another string. For instance, if you have these two words: "horse" and "horsefly" ...
    horsefly will come first in the sort and it shouldn't. This is because the shorter word will be put in bucket 26 until it gets to the first real letter. I did this for simplicity and saved the explanation for Project Euler 22 below. If you want to fix it here and now, just put the spaces in a bucket before the "a." That will make sure it is ahead, and solves the problem!
    Project Euler 22 with Radix - • Up Your Python Game wi...
    0:00 - Background of Radix Sort
    2:47 - White-boarding the Sort
    8:36 - PsuedoCode
    10:55 - Code! Main Function
    15:16 - Code Bucket Function
    21:30 - Remove Padding and Finish

Komentáře • 4

  • @sawyersoucie9462
    @sawyersoucie9462 Před 6 měsíci +1

    Great stuff!

  • @HaleSou
    @HaleSou Před 6 měsíci +1

    Fascinating! I had never heard of this but it was easy to follow.

  • @scottmiller2591
    @scottmiller2591 Před 5 měsíci

    The algo never compared items to items, but did compare the letters from the items with their bin labels, so not really "comparison free." Still, a good explanation.