BATTLE OF THE SORTS: which sorting algorithm is the fastest? (visualization)

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 พ.ค. 2020
  • In this visualization, we run 10 different sorting algorithms in 5 minutes to determine which one is the fastest.
    ⭐ Kite is a free AI-powered coding assistant that will help you code faster and smarter. The Kite plugin integrates with all the top editors and IDEs to give you smart completions and documentation while you’re typing. We made this TH-cam channel and Kite to help you be more productive: kite.com/download/?...
    ***************************************
    JOIN Kite's Developer Community on Facebook ►
    / 505658083720291
    SUBSCRIBE for more Python tips, tutorials, and project breakdowns! ► th-cam.com/users/KiteHQ?sub_...
    FOLLOW US onTwitter ► / kitehq
    ***************************************
    OTHER COOL VISUALIZATIONS:
    3 Levels of Sorting Algorithms - FASTEST Comparison Sort! ►
    • 3 Levels of Sorting Al...
    Simulating COVID-19 using Python, NumPy & Matplotlib [in-depth tutorial] ►
    • Simulating COVID-19 us...
    BIGGEST Codebases in History - Can you guess the largest? ►
    • BIGGEST Codebases in H...
    ***************************************
    Don’t forget to subscribe :)
    th-cam.com/users/KiteHQ?sub_...
    STAY TUNED:
    Kite ► kite.com/
    Twitter ► / kitehq
    TH-cam ► / @kitehq
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 135

  • @sanjacobs6261
    @sanjacobs6261 4 ปีที่แล้ว +301

    This is the sort of video that the TH-cam algorithm will suddenly find in 4 years

    • @note_guessr2565
      @note_guessr2565 3 ปีที่แล้ว +22

      I see what you did there ;)

    • @sanjacobs6261
      @sanjacobs6261 3 ปีที่แล้ว +6

      @@note_guessr2565 I don't... What did I do??

    • @note_guessr2565
      @note_guessr2565 3 ปีที่แล้ว +25

      @@sanjacobs6261 it looked like a pun hahahaha (sorting algorithms, and the sort of video the algorithm o TH-cam would recommend)

    • @sanjacobs6261
      @sanjacobs6261 3 ปีที่แล้ว +22

      @@note_guessr2565 OH SHIT HAHAH I DIDN'T SEE WHAT I DID THERE

    • @note_guessr2565
      @note_guessr2565 3 ปีที่แล้ว +4

      @@sanjacobs6261 😂😂 it was reeally good

  • @kellisuzuki8889
    @kellisuzuki8889 2 ปีที่แล้ว +175

    selection sort: 1830 comparisons
    bubble sort: 1809 comparisons
    insertion sort: 968 comparisons
    heap sort: 952 comparisons
    merge sort: 287 comparisons
    timsort: 566 comparisons
    introsort: 280 comparisons
    quicksort: 286 comparisons

    • @icaro8264
      @icaro8264 ปีที่แล้ว +64

      bogosort: 1 comparisons

    • @hanishparmar7244
      @hanishparmar7244 ปีที่แล้ว +7

      @@icaro8264 if u r lucky 😆😆😆

    • @BlackStarEOP
      @BlackStarEOP ปีที่แล้ว +5

      radix sort: 0 comparisons

    • @Fexisepic
      @Fexisepic ปีที่แล้ว +1

      While time seems to correlate with the number of comparisons, why does that fall apart for the faster algorithms? Why are timsort's comparisons so much faster than merge? Same with quicksort and introsort?

    • @ed7590
      @ed7590 ปีที่แล้ว

      @@Fexisepic Comparisons are just one component of sorting, there's also the action of when and where to move once you've got the result of your comparison.

  • @tannerprewitt4489
    @tannerprewitt4489 2 ปีที่แล้ว +34

    You can't tell me 3:26 doesn't sound like boss music

  • @mfaraday4044
    @mfaraday4044 4 ปีที่แล้ว +29

    Answer- Results depends on the Data

  • @Autrone
    @Autrone 2 ปีที่แล้ว +33

    I like how you simplified and slowed it down enough for our casual eyes to see. I hope that the yt algorithm (heh) sorts you to the top!

    • @softed
      @softed ปีที่แล้ว +1

      TH-cam's recommendation algorithm has a constant time complexity scale of two years

    • @Autrone
      @Autrone ปีที่แล้ว

      lol true

    • @jerryy147
      @jerryy147 ปีที่แล้ว

      @@softed true

    • @MohamedAhmed-le8mv
      @MohamedAhmed-le8mv 6 หลายเดือนก่อน

      what does that mean? @@softed

  • @vasusoni7008
    @vasusoni7008 4 ปีที่แล้ว +39

    Nailed it beautiful representation 😍

  • @CompilerStuck
    @CompilerStuck ปีที่แล้ว +14

    Mergesort is so amazing to watch

  • @minhtoquang8332
    @minhtoquang8332 2 ปีที่แล้ว +7

    Props to whoever did the sound effects

  • @JordanBeagle
    @JordanBeagle 2 ปีที่แล้ว +8

    Nice, although the end card came up too quickly that I couldn't appreciate the glory of quicksort

  • @tim0lmazan162
    @tim0lmazan162 3 ปีที่แล้ว +45

    Why didn't you include bogosort lol
    (I'm kidding)

    • @asddsaasdfg2846
      @asddsaasdfg2846 3 ปีที่แล้ว +3

      Lol my favorite is bogo sort

    • @sealwithawkwardness3951
      @sealwithawkwardness3951 3 ปีที่แล้ว +6

      Best sort also if you get lucky you can get it first shot!

    • @iankravitz5723
      @iankravitz5723 2 ปีที่แล้ว +1

      Because Bogosort is always grumpy!

    • @Xartisxrtfan
      @Xartisxrtfan 3 หลายเดือนก่อน

      Bogo sort added: video length is 48:22:43

  • @morkessler2456
    @morkessler2456 ปีที่แล้ว +15

    1:41
    It’s not an Insertion Sort at all, it’s actually an Optimized Gnome Sort because it shows swaps in it, while Insertion Sort doesn’t have swaps

  • @yeahuh4128
    @yeahuh4128 3 ปีที่แล้ว +42

    why didn't you put quantum sort?
    it finds the correctly sorted list in all possible permutations.
    like Bogosort, but instant.

    • @LordOfSky_41G
      @LordOfSky_41G 2 ปีที่แล้ว +21

      i believe he doesnt have a quantum computer to do it instantly lol

    • @yeahuh4128
      @yeahuh4128 2 ปีที่แล้ว +22

      @@LordOfSky_41G fair reason.

    • @tossboy2643
      @tossboy2643 2 ปีที่แล้ว +4

      Plus that doesn’t make for an interesting visual

    • @amaresh-qq6ql
      @amaresh-qq6ql 11 หลายเดือนก่อน

      Bogo sort is the most inefficient one, its used only for theoretical purpose.

    • @woloexe
      @woloexe 9 หลายเดือนก่อน +2

      @@amaresh-qq6qlit could solve it instantly 😏

  • @ATIHpss64HM
    @ATIHpss64HM 3 ปีที่แล้ว +2

    This is actually really good

  • @andyanderson222
    @andyanderson222 2 ปีที่แล้ว +5

    Hm, heapsort is doing awful for O(n*logn), tbh. Great representation, btw. Thanks alot!

  • @MohdAli-bw1np
    @MohdAli-bw1np 2 ปีที่แล้ว +1

    such a great video

  • @rubikonium9484
    @rubikonium9484 3 ปีที่แล้ว +17

    1:22 sounds like an incomplete F# major scale

  • @D4rK3sTsH4d0W
    @D4rK3sTsH4d0W ปีที่แล้ว

    3:06 Merge sort sounds like in Mario Bros. Classic, when you jump and hit a koopa or something. The comparison part of it reminds me of dig dug.

  • @AleX-hu7ci
    @AleX-hu7ci 7 หลายเดือนก่อน +1

    when part of it were already in order, this would be the time for timsort to shine ;)

  • @daveslamjam
    @daveslamjam 3 ปีที่แล้ว +11

    You're telling me that bubble sort isn't the worst? what?

  • @Legendarial
    @Legendarial 2 ปีที่แล้ว +2

    1:52 epic music

  • @hellopsp180
    @hellopsp180 ปีที่แล้ว

    i really like the weird sounds ahah

  • @kellisuzuki8889
    @kellisuzuki8889 2 ปีที่แล้ว +5

    me: *hm I do wonder which is fastest*
    me after the video: I'm dumb, quicksort literally has "quick" in its name lol

    • @AndrewTSq
      @AndrewTSq 2 ปีที่แล้ว +1

      I did not see bucket sort in this comparsion. That has been the fastest for me (or is it called radix sort.. :)

    • @freewayscity0
      @freewayscity0 2 ปีที่แล้ว

      You’re on 8th, 3rd, 5th place!

  • @callykitten5095
    @callykitten5095 8 หลายเดือนก่อน

    Surely insertion sort could benefit from binary search?

  • @AbAb-th5qe
    @AbAb-th5qe 2 หลายเดือนก่อน

    There is no one best sorting algorithm. Which one to use depends upon what where the data comes from and what state it's in at the outset (mostly already sorted for example). Radix sorting is good but some kind of incremental sort as data is recieved can still beat it if that's possible. Maybe you need to be able to access mostly sorted data before completion, which you won't get from radix sort.

  • @fgomez
    @fgomez 4 ปีที่แล้ว +3

    Also in Spyder, isn't? I have it installed in Spyder.

  • @xbz24
    @xbz24 2 ปีที่แล้ว +1

    nice video visualization, got a bit turned on actually

  • @JordanBeagle
    @JordanBeagle 2 ปีที่แล้ว +4

    I assume different sorting algorithms are better for different applications, or does everyone just use quick sort?

    • @Dorfelsnorf
      @Dorfelsnorf ปีที่แล้ว +1

      Depending on the application different sorting methods may be better. For example merge sort is very quick but does require extra memory for its subarrys which a slower algorithm like insertion sort doesn't.
      But there are clear better options for larger sorting.

    • @swarooprajpurohit110
      @swarooprajpurohit110 10 หลายเดือนก่อน

      No one would use bubble sort though.

    • @whisperware
      @whisperware 8 หลายเดือนก่อน

      Yeah comes down to data size/memory constraints/efficiency and that last one is determined by how the method interacts with the first two.

    • @user-xh9pu2wj6b
      @user-xh9pu2wj6b 7 หลายเดือนก่อน +1

      @@whisperware in reality everybody just uses whatever the standard library sort is as it's good enough in 99% of cases.

  • @JordanBeagle
    @JordanBeagle 2 ปีที่แล้ว +1

    0:35 Does anything actually use selection sort? If so, why?

    • @thomasgabler3476
      @thomasgabler3476 3 หลายเดือนก่อน

      Very easy to implement (just 2 for-loops), fast enough for small amounts of data. I prefer it to bubblesort when I teach arrays.

  • @bickblakkok
    @bickblakkok ปีที่แล้ว

    Song name at the start?

  • @dhanisandyanto475
    @dhanisandyanto475 2 ปีที่แล้ว

    Start from 0:30 and set playback speed 0.25, you will hear nice melody

  • @gammaboost
    @gammaboost ปีที่แล้ว

    Merge sort may contain traces of ringtones

  • @khaledk13
    @khaledk13 2 ปีที่แล้ว

    radix sort plsss

  • @blackholegt
    @blackholegt 10 หลายเดือนก่อน

    1:02 115! *INSERT GUITAR*

  • @turanbirligi6969
    @turanbirligi6969 7 หลายเดือนก่อน

    pigeon hole sort?

  • @maurolionelmipianoyyo11
    @maurolionelmipianoyyo11 2 ปีที่แล้ว

    Quicksort…
    Thats why its so quick
    *Quick* sort

  • @martinsgaming-kanal7727
    @martinsgaming-kanal7727 4 หลายเดือนก่อน

    The fastest sorting algorithm I know is "Radixsort (LSD)".

  • @armybrat2869
    @armybrat2869 4 ปีที่แล้ว +7

    Quick sort is the answer!

    • @user-nb6zu3rk4f
      @user-nb6zu3rk4f 3 ปีที่แล้ว +1

      No

    • @sajeucettefoistunevaspasme
      @sajeucettefoistunevaspasme 3 ปีที่แล้ว +1

      Depends of the context
      Like with every algorithme

    • @dale116dot7
      @dale116dot7 3 ปีที่แล้ว

      Radix sort works very well if you’re trying to sort a deck of punched cards you had your FORTRAN program on. And dropped. O(n). Depends on what you’re trying to sort.

    • @abhisheksharnagat4508
      @abhisheksharnagat4508 3 ปีที่แล้ว

      In common, yes

    • @freewayscity0
      @freewayscity0 2 ปีที่แล้ว

  • @arunsharma8740
    @arunsharma8740 ปีที่แล้ว

    Babe I lied, there is no Netflix, today we are gonna watch sorting algorithms

  • @rubikonium9484
    @rubikonium9484 3 ปีที่แล้ว +4

    1:11 - 1:12 sounds like B major

  • @GeodesicBruh
    @GeodesicBruh ปีที่แล้ว

    Where is bogosort the best alg?

  • @sleevman2307
    @sleevman2307 3 ปีที่แล้ว +3

    Yo quicksort cheated, it had "quick" in its name

  • @Luukra
    @Luukra 2 ปีที่แล้ว

    is this dubstep?

  • @Exotic69420
    @Exotic69420 2 หลายเดือนก่อน

    blud really wants us to use kite

  • @master138
    @master138 ปีที่แล้ว

    Can you test the cpp's std::sort()

    • @deanlongmire6166
      @deanlongmire6166 ปีที่แล้ว

      I’m pretty sure it just uses quicksort

    • @user-xh9pu2wj6b
      @user-xh9pu2wj6b 7 หลายเดือนก่อน

      @@deanlongmire6166 nope, it's introsort.

  • @t0xicrunner
    @t0xicrunner 2 ปีที่แล้ว

    Earthbound music be like

  • @Rockyzach88
    @Rockyzach88 2 ปีที่แล้ว

    Why put junk all over the screen on the best one?

  • @FairButNotReally
    @FairButNotReally 3 ปีที่แล้ว +1

    I am probably the only one who searched for this...

  • @didierdeschamps8557
    @didierdeschamps8557 ปีที่แล้ว +1

    Radix sort LSD should be number 1.
    Why did you forget it ?

    • @user-xh9pu2wj6b
      @user-xh9pu2wj6b 7 หลายเดือนก่อน

      because it can't sort arbitrary objects, just integers. And if you want to include all sorts in general, then Bitonic or odd-even merge sorts will be the best with time complexity of O(log(n)).

  • @wendyvicodin8745
    @wendyvicodin8745 2 ปีที่แล้ว

    Where is pigeonhole ?

  • @66palach
    @66palach 2 ปีที่แล้ว

    Showing the annoying ad hundred times is unlikely to make people instantly download the thing...

  • @LrielMC
    @LrielMC หลายเดือนก่อน

    ofc quicksort gets it

  • @blockshift758
    @blockshift758 ปีที่แล้ว

    Where my binary sort

  • @ddniel
    @ddniel 3 ปีที่แล้ว +1

    See you in 2026

  • @LittleFarmLife1637
    @LittleFarmLife1637 ปีที่แล้ว

    00:03:19 ааррааььббссккааяя ннооччььъъььъуъьуь

  • @jd-dev
    @jd-dev ปีที่แล้ว

    I prefer bozosort

  • @brayansaldanha8358
    @brayansaldanha8358 2 ปีที่แล้ว +2

    I don't know why we are even made to learn bubble sort....it's the worst sorting algorithm.

    • @Luxor-ok9hj
      @Luxor-ok9hj 2 ปีที่แล้ว +2

      I think because it's the easiest one to learn(expect bogo sort) and does his job properly for small arrays

    • @user-py8bq2pk1h
      @user-py8bq2pk1h 2 ปีที่แล้ว

      it's for beginners bro

    • @freewayscity0
      @freewayscity0 2 ปีที่แล้ว

      You’re on 7th place!

  • @derpthegreatest
    @derpthegreatest ปีที่แล้ว

    bogo solo's

  • @anthonyhu6705
    @anthonyhu6705 2 ปีที่แล้ว +1

    No bogosort? Unliked, unsubscribed, and uncommented

    • @antrix2107
      @antrix2107 11 หลายเดือนก่อน +1

      uncommented lmao

  • @vpexmc
    @vpexmc 3 หลายเดือนก่อน

    Stalin sort is faster :/