Selection Sort Explained (& Crushes BubbleSort!)

Sdílet
Vložit
  • čas přidán 9. 07. 2024
  • Selection Sort for this Algorithm Monday (and coding in Python) is a huge upgrade from bubble sort and a small increase from insertion sort. Still a O(n^2) but a very simple and easy way to continue your computer science and algorithm journey. Don't forget to check out the playlist for more sorting and algorithm fun and make sure to subscribe for future content!
    Sorting algorithms playlist: • Sorting Algorithms
    Algorithm Monday's playlist: • Algorithm Monday
    0:00 - Intro
    1:12 - How it works
    3:35 - Selection sort is the natural human way
    4:09 - Better than bubble sort/selection sort
    5:01 - Best case Big O
    5:57 - Python
    8:41 - Slight optimization
    9:15 - 1 million vs bubble and insertion
  • Věda a technologie

Komentáře • 3

  • @ahmad-murery
    @ahmad-murery Před 2 měsíci

    I like it,
    Do we need the last iteration of the outer loop?
    It's probably more fair to test all of the 3 sorting algorithm using the same random array.
    Thanks Rob!

    • @robertbunch-dev
      @robertbunch-dev  Před 2 měsíci +1

      Ya, poor bubble sort may have gotten a lousy draw :) I was hoping the array was big enough that it didn't matter.
      I must have mis-cut that update because the last iteration is unnecessary. Naturally if all the other numbers are sorted, that one is too. It will be minimal operations, but ideally goes to:
      for i in range(len(arr)-1):

    • @ahmad-murery
      @ahmad-murery Před 2 měsíci

      @@robertbunch-dev I came from a background where resources are very limited, so eliminating one operation here and there can sum up.
      Thanks Rob for your great work