I Made Sorting Algorithms Race Each Other
Ойын-сауық
Don't click this: tinyurl.com/bde5k7d5
💚 Link to Code: / greencode
⭐ Other Social Media Links:
🔊 Discord: / discord
🐦 Twitter: / thegreencoding
📸 Instagram: / greencodecodes
🎵 Tiktok: / greencodecodes
🔊 Music I Used in this Video: share.epidemicsound.com/7i1d0b
✨ Subscriber count: 11,754 subscribers 💚
Пікірлер: 185
There is a parallel universe where bogo sort won.
@kianchristopher7704
5 ай бұрын
stalin sort going ham
@maxwell6881
5 ай бұрын
@@kianchristopher7704 (Un)fortunately, there is no parallel universe where stalin sort won.
@idkwhatnonamemyself1951
Ай бұрын
Quantum bogosort moment
@poopyfarts6848
Ай бұрын
if there are infinite parallel universes, there is a universe where bogo sort always works and nobody knows why
@dannyhoang9623
Ай бұрын
Always bet on bogosort
So you technically sorted the sorting algorithms
Next, make them *arm wrestle*…. Two sorting algorithms, one list; one trying to sort the list ascending, the other descending.
@CaptainJellyBS
5 ай бұрын
THAT IS SUCH A FUN IDEA!
@JensRoland
2 ай бұрын
“Innnn the right corner, built by a team at Google DeepMind, the challenger with four straight victories in a row including two by technical deadlock. This brainy bot will put you Out Of Order, iiiiit’s AlphaSoooooooort!”
@GeminiEntropic
2 ай бұрын
I need this in my life djshisbd
@farpurple
Ай бұрын
Somewhat hard with some algorithms, like merge sort it is recursive, maybe each call revert it hm
@adeonn
Ай бұрын
That would b really funny with bogosort
The reason .sort() is faster than the other ones is because it was programmed in C, while the ones you made are in python.
@Green-Code
5 ай бұрын
Yeah I'm aware :). It's just kinda of frustrating that after learning about sorting algorithms in Python, there's just a function that does it like waaaay better than anything you could do in Python :)
@puppergump4117
5 ай бұрын
@@Green-Code You could always do it in c++, but then you'd have to rename yourself Red-Code
@DendrummerMC
Ай бұрын
Love content like this.... But I have one critique that was not mentioned in the video afaik. There's no "one size fits all" sorting algorithm, though some algorithms certainly are better than others in the majority of cases. Parameters like the size of the list, the type of data in the list and how the data in the list is ordered can make a major difference for example, as I'm relatively sure the wikipedia page on sorting algorithms points out. A truly fair competion as I see it would have categories. In one axis short, medium and long distance (aka n. I'd say n=1.000, n=100.000 and n=10.000.000), in another axis swimming, running and cycling (objects, strings and integers) and in the final axis a suny day, a windy day and a stormy day (almost sorted, fully random and p much reverse order). That being said, keep up the good work. ( ^ v^)b Ps: poor bogosort being called the worst when bogobogosort exists :P EDIT: meant to send as original post not reply xD oh well too late
@waveplasma1369
Ай бұрын
@@Green-Code It also uses timsort or powersort which are slightly better versions of mergesort!
@alansmithee419
26 күн бұрын
@@DendrummerMC Don't forget quantumbogosort. Randomise the list. In at least one universe (as per many worlds interpretation) the list is now sorted. If it is not sorted, destroy the universe you are in. You are now left in a universe where it is sorted (as per quantum immortality).
Me: can we have code bullet? Mom: we have code bullet at home. Code bullet at home:
@Kristanoppersma
Ай бұрын
Great Video though
@noahscott4096
Ай бұрын
I was gonna say. Kinda like code bullet without the depression.
@Pelumi-lk9dz
Ай бұрын
But still.. This guy is SICK.
Should have implemented some of them with threads, as mergesort and quicksort are easy to parallelize and get much faster. For Quicksort, you don't even need synchronization.
@Green-Code
5 ай бұрын
Didn't know that. So thank you for the info :)
@Julianiolo
5 ай бұрын
at 100 elements using threads will probably be slower. Also this is in python where there are no threads :)
@morl1273
5 ай бұрын
@@Julianiolo yes that's true, but this is in general a measurement bias in this tournament. First we need longer numbers, as radix sort is O(n*m) with m being the number of digit's, while for other algorithms the number lengths is irrelevant. Also we need more numbers to gain actual data and we need them tested multiple times to get valuable data.
@morl1273
5 ай бұрын
@@Julianiolo also there are python threads, but they indeed have a problem that they are often not executed in parallel but instead are reduced to linear code execution
@Julianiolo
5 ай бұрын
@@morl1273 "threads" in python only help when dealing with i/o and similar, since they cant use multiple cores. Multiprocessing is kind of the equivalent for python, but that has other issues.
in a perfect universe Bogosort wins everytime
Very interesting. Thanks for your work. Looking forward to the next one.
You should make different categories with different amounts of elements, for example 10, 100, 1k, 10k, 100k, ... and see how for example insertion sort dominates everything for the lowest category (if it is few enough elements), then quicksort dominates everything in the middle and then the big O complexity of radix sort enables it to outrun everyone else. Also, it would be in the spirit of Olympics because there are different sports (= different categories) Nice video though, you deserve way more subscribers!
@redder358
Ай бұрын
Oh and maybe in the future, you could host some competition where people send their algorithms and you let them run and compare them, similar to what Sebastian Lague did with chessbots last summer. That way you would have plenty of algorithms and it could be a really interesting content that I have never seen before on KZread.
@m_affiliates
23 күн бұрын
@@redder358imagining the winner would be some maniac who wrote both a compression and decompression algorithm and packaged holygrailsort into 2KB
Awesome video! I think a potential factor in why the tournament results were a bit off comes from how the n value was changed from bracket to bracket. Because of the different time complexities, some sorting algorithms might work faster with smaller values and so they might start floundering as the list size increases.
There should be separate categories for algorithms that need extra memory, and ones that dont.
@Green-Code
5 ай бұрын
I know, but I didn't want to make the video more complicated
@stephenhowe4107
Ай бұрын
@@Green-Code And also which sort is stable and which is not. And which sorts have O(N) behaviour if the data is mostly sorted
You should host a Nerd Olympics. I had never been more excited to watch sorting algorithms in my life! Good video.
@GPSdotGlitch
Ай бұрын
I agree 100%
I really like your character, and AAAAH YEAH MERGE SORT LOOKS COOL
This was a such a blast to watch :D
I like watching random sorting algorithms, but it’s nice having someone talk about them while I watch
Why we have all of these to begin with: - some algorithms are what we call "stable". this means that the order of elements that have the same value for the property we are sorting on does not change - some algorithms work in-place, whereas others need to make a copy of the list. Algorithms that are not in-place use more memory and sometimes don't utilize CPU cache well. - the speed of an algorithms sometimes depends on what list you are sorting. Quicksort has a best-case time complexity of O(n log n). but it can perform as bad as O(n^2), if the list is organized such that the chosen pivot is a minimum or a maximum of the current slice. Merge sort on the other hand, has a time complexity of O(n log n) no matter what. - Finally, radix sort is a bit different from the rest. It performs O(nk), where k is the average number of digits a number has in the list. But the trouble is that radix sort is unwieldy to implement when you want to sort data that isn't plain integers or strings. also, if your list is small and your number of digits high, radix sort can be as bad as bubble sort.
This deserves more views. As a programmer, this is pretty investing and cool
gg man love the video
bogosort has (16 sorting algorithms, same style) 1/[(100!)^4] chance of winning, which is still more than the chances or your dad coming back
Get this man a million subscribers
It is also important for the move ordering in the minimax with AB pruning
from one mergesort enjoyer to another 🤝
5:50 got me so confused, you speak about radixsort while showing bubble sort and bucket sort 😅
Quick sort and Merge sort are the GOATs
codebullet but faster uploads, subscribed :3
5:40 Radix sort is bucket sort and bucket sort is bubble sort
@ziggyzoggin
5 ай бұрын
Yeah that bugged me too.
4:45 I wonder how insertion sort would do if binary search were implemented. But probabbly to that much better
You should add Counting Sort. It only works for positive integers (can easily be modified for negatives) though.
Every sorting algorithm has it's advantages and disadvantages, so it depends on the situation. If you have always a lot to sort, then one algorithm may be better, while if you have small amounts of data to sort, then another one may be better, etc. Also, even if algorithms have the same time complexity, they may differ with how good the best case is, etc. Also, just because one algorithm has a better time complexity, it may be worse than one with a worse time complexity if it does a lot of expansive calculations, and the one with the worse time complexity does less expensive calculations. ... Though bogo sort is always bad.
Some of those poses look quite similar to Code bullet 😉
yo the radix sort vs bucket sort part had the names from the previous round, make sure to watch your video before uploading
You really put your Channel Description in binary😂 I respect that.
Makes me want to write my own test, but in C. I figure I could either visualize it with colored terminal output, or alternatively use RayLib.
Actually, many sorting algorithms have complex behaviors, being able to detect when a sub set is getting slow, when that happens the sorting strategy changes
Wow I actually was using a shitty sorting algorithm when I was scripting and ordering an array that had distances, I learned something...
1:49 it's upside-down because the Y axis is orientated downwards. 2D graphics are like this probably because computers handle ordered things from left-to-right and top to bottom, like text.
i have a bit of thoughts on this video 1. those single letter variables.... 2. yes i love comb sort or shell sort... idk it's hard to tell them apart Ӡ. pretty sure radix sort screws up when sorting floating point numbers 4. that pixel font has no descenders... AHHHHH
2:30 Actually, Bogo Sort's best case cenario is when the list is already sorted taking n-1 comparisons and could technically win and Merge Sort... 6th.
what are you using to visualize the sorting algorithms ?
should've made em race in different categories like: small arrays, almost sorted arrays, extremely large arrays n so on
you should inplement sleep sort, with multi threading as it is fastest with small datasets, also at 5:49, it reads bucket sort, when its radix sort
Bogobogosort has this in the bag 💥
The fact that bogosort is the fastest sorting algorithm in a quantum computer or an hpc system where all possibilities are tried by each computing unit at the same time 😎
5:07 was kinda best, I guess
you haven't tried Wikisort or Grailsort? they are modifications of mergesort that are supposed to be fast, stable, and need no memory.
@paulstelian97
Ай бұрын
They're also awfully complicated to implement.
While this is small enough that they probably won't bother you, I did want to let you know that the Olympics is a trademarked or copyrighted thing and they _do_ go after some creators. The one I'm thinking of is a really big one, the MarbleLympics (now Marble League). Not a criticism or saying you should change anything. Just thought I'd shoot you an fyi
Radix is an odd one there. There is a way to make it super slow with complicated data, or super fast with very simple inputs. I would say quicksort is the champion of the comparison sorts.
How do you make your animations with mouth movements and so on?
Cool video i guess but i'm a bit disappointed by the lack of necessary informations, like: on what hardware was the test run on? Was the code written in a statically type language? Did the code made use of multithreading and avx optimizations?
Remember, bogosort has an 1/100! chance to instantly win
I'm also fan of merge sort and I even noticed at the begining of the video that you were using mergesort as example animation. You should try non-recursive version of it which is much faster, also you can make it even faster if you are using hybrid algorithm. You can first sort every for example 32 numbers using insert sort which is faster for smaller data (I didn't test if 32 is optimal it's just example) and then from that moment you can start merge sort. also it should be better to test it in compiled language like C, C++ or Rust because python has hudge overhead (it is possible for python algorithm to work even 40 or more times slower!) and this overhead can potentially be different for different algorithms.
at 5:40 I think you chose Bubble sort instead of Radix sort EDIT: What was I thinking? It just says Bubble sort at the top, but the algorithm itself is Radix sort. EDIT 2: As I continued to watch the video, I realised that that whole section is quite confusing.
@londonl.5892
5 ай бұрын
I went through this exact process
@Green-Code
5 ай бұрын
Yeah sorry about that :/. The editing for this video was a bit gruelling and I forgot to change the names of the algorithms (although the algorithms themselves are the correct ones).
@pushkal8800
25 күн бұрын
Bro fire video too too good loved it man the visualizing idea and the meme olympics way too good, love you brother
Some algorithms work quicker in large data, some work faster with less data.
Would be interesting how sort() works tho
nice video
where were you when i was getting cooked in DATA STRUCTURES & ALGORITHMS
Loved your video. Just tiny notes, Bucket sort is faster partly because it's a different class, The others presume your only operation is Comparisons. Bucket sort as you mentioned uses some element inspection which makes it leaps better, actually Counting sort might be the best here, since it'd sort the array in O(n) (not even that just plain 2n+c, I think), but in usual general cases where these are compared these two cannot be applied, which doesn't mean ofc that they aren't awesome, useful and shouldn't be mentioned. Second "like not supposed to be that good" is referring to asymptotic complexity which assumes the length of your inputs "approaches infinity". So sometimes bubble sort wins if you have like 3 elements. To make this fair and interesting you have to do probably millions of elements, otherwise the constants in those algorithms might trump the asymptotic complexity itself (which I guess depends if is relevant to you)
Please I want to see a battle of the sorting algorithms against 'cosmic ray sort'. From the start to the finish. Real time, no speed up.
You not let stalin sort compete😂
What did you use to build the visualizer?
Bro forgot sleep sort 💔🙂
green code do you not realize at 5:40 you put bucket sort and bubble sort together from their titles above instead of "Radix sort" and "Bucket sort"
do you use lazykh for animating? (not hate btw)
some sorting algorithms are faster in small datasets than in large datasets (shut up i know hybrids exist) its like how O(n) is faster than O(n log n) sometimes or at least i think im the one who supports bubble sorting cuz ez to program
Time to add multithreading :P
this is unfair you should test different case, and radix sort is just fast,but cannot use in real case.
hey uhh fun fact radix sort was invented *_B E F O R E C O M P U T E R S_*
nice video, can't wait to see more
i spent 8 days trying to make this shit work and it wont im lossing my fucking mind
Why did you leave out binary search from insertion sort? That's literally the entire point of having a sorted array.......
Where is my favourite sorting algorithm? Stalin Sort would absolutely win!
5:41 isn't it supposed to ve Radix sort vs Bucket Sort? You wrote bubble vs Bucket
I mean there are lots more sorting algorithms you could have put in. I would look to ArrayV personally for more sorting algorithm type things. Also, I wouldn’t say this is a good way to compare sorting algorithms because, example, the second fastest sort could be knocked out by the fastest sort in the first round. I feel that it’s better to analyze each individual sort and look at their times for multiple data sets.
why did i watch it fully ,
should try bead sort
can you make a course in python for intermediates
5:43 shouldn't be here bucket and radix(instead of bubble)??
Radix sort has comparison part of bubble and bucket sort only 😅
You are comparing algorithms that work for any data (that is, general ones) with those that only work for specific types of data. The first ones only use the "
video starts at 4:00
People are saying that the bogo algorithm is still running🤣
Did you really forgot the best one the stalin sort
5:40 ARREST BUCKET SORT AND RADIX SORT THEY COMMITTED IDENTITY THYEFT !!!!
implement pigeonhole sort
Bogo sort is my only choice
5:41 I think, there is a typo. You said radix sort versus bucket sort, but there is written bucket sort and bubble sort in the video.
@Green-Code
2 ай бұрын
Yeah there's a type :(. Sadly I don't think I can re-upload.
you made a mistake at 5:40, you said radix vs bucket and then put bubble vs bucket at the top of the screen
Memory complexity of each?
Okay, but what about Stalin Sort?
Not a furry A normal dude not trying to be something different Lip syncking What else can i ask for
Deaf people: 🤩 Blind people: 🛸
Bro, why the lack of explanation at 4:00 :( Also didn't mention that extreme little difference between Heap and Merge in 1/8. Not cool. HeapSort algorithm is cool af while being simplistic enough, and in times (personally didn't encounter such times, but, still) when you need to write your own sort, HeapSort or MergeSort are usually the ways to go. 5:40 it shows BucketSort instead of RadixSort. How does the BucketSort work though?.. Looks similar to ShellSort.
Hey the text at 5:40 is wrong its showing the wrong names
@Green-Code
5 ай бұрын
Yeah :( Just realized that now. Sorry for the confusion.
bulletcode's son:
5:41 Radix Sort vs Bubble Sort, yet you labeled them Bucket Sort vs Bubble Sort.
@Unlimit42
Күн бұрын
Left is Radix sort, right is Bucket sort.
You used the wrong quick sort. Use quick sort with left/right pointers, it is faster
3:47 BRO UR BLOCKING THE "TAIL" LOOK AT THE TEXT NOW
Lietuvis? fire video tho
This is not a fair comparison, look at the space complexity of radix sort, then quick sort will win!
hello, what's your name?