50+ Sorts, Visualized - Reversed Inputs
ฝัง
- เผยแพร่เมื่อ 9 มิ.ย. 2019
- Visit our community Discord: / discord
This bar graph visualization features 54 different sorting algorithms sorting inputs that are strictly decreasing.
*NOTE: Some algorithms with pathological inputs are skipped partway in this video to save time.
Try out the program featured in the video here: github.com/gaming32/ArrayV-v4.0 - วิทยาศาสตร์และเทคโนโลยี
Join our community Discord! discord.com/invite/2xGkKC2
Rip no likes :(
You: Gnome Sort
The Guy she tells you not to worry about: Optimized Gnome Sort
You've just been G'Nome Sorted
Her father: Odd-Even Sort
Lol 😹
(insert keemstar joke here)
Max Heap Sort
"Yo pass me the aux cord"
"You better not play trash"
*plays the In-Place Radix LSD Base 16 Sorting of reversed inputs with 2,048 numbers*
timecode ples
Timecode: 11:10
timestamp*
Alluseri timestamp: 11:10
My jam
Every other sort-uses givin values
Gravity sort-yall mind if I just *c h a n g e t h e v a l u e s*
What if i set them all to the same value BOOM
Sort skill 100
pizza mozzarella pizza mozzarella rella rella rella rella
@@tiporial this comment could be a big hit in Europe
9:46
18:20 "ok let me fix that... wait... no... what's going on??"
This comment is not cool 😻💪👎🤙👎😽💪👎😻👎🙀👎😼🤞🎃👺👹
Ixpantenco it's pancake sort
@@estergallardo3594 And you're cool I suppose?
It's just robot
@@spedur3361 found the thirteen year old
Programmers in theory: look at all these options we have for sorting in different situations
Programmers in practice: std::sort
superscatboy truu
Pigeonhole sort requires a limited range of integers (or equivalent). Using pigeonhole to sort a list containing just the numbers 1 and 1 trillion (1000000000000) requires 8TB of storage for example. It's great when you have a large set of integers in a small range, but that's almost never the case in practice.
quicksort when
_Arrays.sort();_
16:27 when you have five minutes left to finish all the questions in your exam
lmao that actually made me nose laugh
nose expiration
ye lmao, it got quick so weirdly
I finally understand how gravity sort works! It doesn’t sort by moving, it changes the value of the item in each place until it’s the right value for that place
Yup! Uses a lot of scratch space in memory to do all that subtracting/adding, as well.
What is min heap sort then?!
@@Musicombo how about counting sort?
Can you give an example using numbers?
@@mrninjagon270 @chacha charlie well technically you can consider non descrete values to be discrete, but there is only 1 of each value. It would be really inefficient, not impissible for the counting sort
Smooth sort: is called smooth sort
Also smooth sort: 5:24
Spiky
pointy sort
I was just about to say that ! It's literally the least smooth of all, maybe excluding heap sort variants.
Casey Ashworth I think it’s called smooth sort due to how quick and clean the sort itself is
Ru²Kanga clean?
17:21 Introsort: Well, I just completed my task, better celebrate!
pancake sort be like
bruh
Man, not all sorting algorithms are designed to work with purely this type of data. Probably it was developed for something very specific
Yeah, it certainly is. I got time and checked. The only available operation is element flipping, so it just wasn't designed to work in this data type
18:20
The sort took 3 minutes
my mans be like bruh
dannad x what the heck is pancake sort for then?
2:12 looks like a rotating 3D image. Nice
It does!
Omg it does lol
true tho
Yeah, it's like watching someone rotating an empty box
Set Playback Speed to 2 to improve the algorithms
big brain moment
Or 720p60
No
4:43 And here, you see a sorting algorithm sorting a reversed input to another reversed input...
Min heap sort is just wrong.
4:49 SIKE
@@edwardclark6731 no
9:57 wait that’s illegal
ikr
is this how they made earthbound sounds
Hahaha :P
No.
@@jacobw1780 r/woooosh
@@Pedro270707 O H N O
pk algorithm
2:50 my guinea pigs when I'm cutting bell peppers.
I’m glad someone had the same idea!
poor pancake sort
18:22
It tried, but it just wasn't enough
Still faster than bubble sort
It's a joke sort so its born to be trash unfortunately
It's just showing off.
Patience Sort: get your popcorn and take a seat, we're gonna be here a while
Also Patience Sort: 2 seconds
thats terribly inefficient if it was real time
16:24
"Nope, I'm done"
26:34 So we've made the pattern just the reversed version of what the order is supposed to be, so its easier for you to sort them.
Less Bogo Sort: Ok...
omg yes
Yeah
relatable
Bogo Sort can be the fastest sorting algorithm, with the chance of happening of 1/n!
I may be late but is that 1 over n factorial or is it an excited 1 over n ?
@@DragoStar this is probably a joke, but hey, anyway it's n! since thats the total number of ways to order n elements
@@DragoStar 1 over n factorial
@@DragoStar 1 over nfactorial
i really love 10:36 so much! easy algorithm and yet best performance~
Ah yes. 573 microseconds ERT, just behind of TimSort (391 microseconds ERT, 16:32)
It's a storage and memory (?) hog though.
pigeonhole sort just built different
elements 1 and a really, really big number
Imagine using silly sort on a comically small set, thinking “maybe it’s silly’s time to shine,” only for your computer to freeze for seventeen and a half seconds before presenting a sorted set
A set of 256: 17,5s
A set of 2048: 1m41,6s or something
It doesn't work like that; it's not linear complexity. 2,048 items would probably take over a day.
@@Musicombo Ah, the beauty of O(n^(log n)) (didn't know that it was that bad while I was making that comment)
Silly Sort took 572 MILLION COMPARISONS to sort 256 items!! XD
10:29
_What._
“yeet”
The algorithms have learned to count
Galimantis 10:37 *
Count Count Sort
H O W
21:34 flight of thr bumblebee
Love how the smooth sort (5:24)is in no way smooth
LMAO
Smooth sort actually roughened up the surface of the triangle
5:25 I’m sure that is not smooth it looks sharp
no
I’m pretty sure it’s called that due to the sporting not being sloppy or confusing as others
smooth heaps: *am i a joke to you?*
Future me: *Yes. Yes you are.*
When bad sort gets to be one of the fastests
Good sort
well it doesnt use as much numbers so...
Batcher's bitonic: *"yes, but actually... no"*
it does make some pretty fire beats if i say so myself
That's just what happens when you're literally the opposite of adaptive!
That’s at 12:58
Also what the $%#&?????
And then there's Pancake sort at 18:20.
Base 16 looks like it’s trying to say something
Sounds like it's trying to say something; not sure whether that's what you meant to say or just what I think
11:11
TimSort be like: "Y'all mind if I just flip the array?"
Est. Real Time: 391 microseconds.
12:58 Batcher needs to make up his mind
17:21 sounded like All Star for a second
nice 69th like
Omg ur right
I like how min heap sort went through the whole heapification process to only end up back where it started
See, YOU can see all the items at once , but the algorithm cant. It can only compare two items at a time. To us, it just looked like Min Heap Sort turned a reverse array back into a reversed array. But to Min Heap Sort, it turned an array of didn't know was reversed, to an array it DID know was reversed.
I like it when the red line is stuck focusing on one point like it's working super diligently to sort the things in the area, then it goes to another place and starts again
so is no one gonna point out that min heap sort did a bunch of stuff to the inputs only to get right back to where it started and then flip it around
I thinks it's absolutely amazing that bogo sort with 8 inputs took nearly 10x as long (estimated) as quicksort with 2048 inputs
And that’s without even talking about pigeonhole sort
@@Hasde_dfs tim sort
@@Hasde_dfstime stamp?
Wait til you see BOGOBOGO sort…
@@locrianphantom3547with 10 inputs!!!!
2:17 it looks like a hole in a box lol
I like the ones that don't even maintain the integrity of the original data but somehow put it all back at the end, like the gravity sort
12:27 The sound of 100, 500, and then 1000 point enemies being destroyed.
Counting sort: I am speed
Patience sort: You are quick, But im faster
Time Sort: Hold my beer
TimSort: Try me bitches
Pigeonhole Sort: Boom, done! What now?
Pancake sort: YOU DARE OPPOSE ME MORTAL
Hold on gotta scan the algorithm 69420 times before confirming its sorted
pancake sort: merry christmas 2016!
3:02 if you listen closely it almost sounds like megalovania
Obviary god damnit take my like
42th
I'm surprised Pancake Sort didn't see the obvious solution of just flipping the entire stack once to get it in the correct order. I presume there's a limitation to the algorithm (which I am unfamiliar with) that forces it to start inside the stack, thus preventing it from just flipping the whole thing in one shot.
Pancake Sort searches for the largest item in the remaining list, and then reverses the part of the list ranging from the first item in the list to the largest item. For example, if the largest item is the 50th item, reverse the order of the first 50 items. This puts the largest item(in the remaining list) at the front of the remaining list. Then you reverse the ENTIRE remaining list, putting the largest item in the last position in the remaining list. Then redesignate the last(largest) item as part of the sorted list. Then do it again on the remaining list, until it reaches a length of 1 item.
It's basically Selection Sort, but made much worse for no reason.
So, in this case, on the first iteration, it finds the largest item(already the first, as the list is in descending order), then reverses the list from the first item to the largest item(since this is a list of 1 item, nothing happens), then reverses the entire list, which sorts it. But the algorithm doesn't check if the list is sorted, it just searches for the largest item in the remaining list. Because it reversed the entire array, putting it in ascending order, the largest element in the remaining list is at the end, making the algorithm reverse the entire list to put the largest item at the beginning, then reverse it AGAIN to put it at the end and thus sort it. But it isn't checking, every time it reverses the array, if it's sorted.
In short: although it sorts the list in "one shot," it doesn't KNOW if did that, cause it didn't check. Hope that answers your question.
11:10 - is drop from dubsteb
which
dubsteb
Nobody:
Old PCs when you put in a CD: 18:13
Whoops! You have to put the CD in your computer
9:57 Perfectly balanced, as all things should be.
9:58
@@thatonecountryballanimator It's already unbalanced at 9:58.
Whoops, sorry.
Where's that comment with the list of sorts?
Gone Reduced to atoms
Seems not sorted yet
11:11
the time, the sort, the mathematical perfection of it all
batchers bitonic be like:
Ok yeah, go there, uh huh, wait stop! Go back, go back. go right there. Yeah. WAIT NO COME BACK HERE!
16:32 timsort's not having any of this reverse bullshit
Some of those look to me like (1) read the list (2) print the sorted list is the whole algorithm. I can not even begin to guess what is going on.
Also, silly sort looks like a merge sort that got neurotic and is afraid the list might change when he is not looking
They use auxiliary data structures. The visualization really should show them
Batchers Bitonic Sound be like:
"now i know this might look like the exact same thing but just hold on for a bit"
7:52: the best one
Merge sort is kind of how people sort things, you group similars together and then pick out the similarities to those groups and so on until 0 to 100 are lined up
odd-even sort looks like a 3d structure changing shape.
It does tho
Is no one going to mention that at one point gravity sort had all of the numbers the same?
You should look up gravity sort. It's a really cool concept. You could build a physical system using it to sort in linear time. It is also called bead sort
It's pretty cool but unfortunately it's not very efficient
I saw from another comment that it changes all the values until its the right value for the place
Choinkus Gravity sort is only good on specialized hardware. Of course, if you implement it on hardware, it’s very fast.
@@ironoat I know
@ Pancake Sort: BRUUUUH WHAT ARE YOU DOOOOOOING
Pigeonhole sort is like "I SEE THROUGH THE LIES OF THE *reversed inputs"*
Time sort: Estimated Real Tome: 8,192 ms
That’s only 8.1 seconds, but it feels like eons compared to the rest of the sorts...
Edit: never mind. Silly sort and slow sort killed it. Lmao.
Yes, because time sort works by waiting in many threads at once.
Tournament sort?
That's because time sort isn't a real sorting algorithm. As the air accumulator said, time sort is just a horrible abuse of the system's scheduler - it creates one thread for every element, makes them wait (value of the element × 4) milliseconds then push the element onto the end of the output array, then insertion-sorts that array.
Slow sort
@@lithiumwyvern_ ngl that's kinda genius
Everyone gangsta til odd-even sort makes the sorting 3D
Really shows the difference between n^2 vs nlog(n)
I find pancake sort very funny when it starts swapping rapidly towards the end
I wish you would do a bit of color coding for what state the sorts are actually in- say green for "known to be sorted", and maybe separate colors for each layer of heapsort's heap
nice pfp
No matter what the sorting video is, Radix LSD Base 4 NEVER fails to impress me in terms of awesomeness and beauty. :)
And it also sounds great.
This made me curious, is there an algorithmic way to find the specific “worst case scenario” for any given sort? Between this and the already sorted inputs, it certainly seems like there are some non-random arrangements which take excessive amounts of time compared to a normal sort.
It's probably more often that people have just come across worst cases for these sorts, but I'm not sure about an algorithm. I would be curious about that, too!
I'll try to prove that there doesn't exist a general algorithm for that, in a similar way that you prove that there is no general way to solve the halting problem:
Assume that there is an algorithm A(s, i), that tells you whether an input i is the worst case input for a given sorting algorithm s
Construct sorting algorithm S, that given A(S, i), will sort using quicksort if i is the worst case input, and otherwise use bogosort (or any other algorithm that is going to be slower than quicksort)
But, this means that for I = worst case input for S, A(S, I) /must/ say that I is not the worst case. Therefore, there exists no general algorithm A that can determine if a given input is the worst case scenario for a given sort.
I hope this makes sense :)
@@erikprantare696 That does, thank you so much!!
"Between this and the already sorted inputs, it certainly seems like there are some non-random arrangements which take excessive amounts of time compared to a normal sort."
While that seems true, there are exceptions. For instance, insertionsort is faster for "nearly-sorted" and "completely sorted" lists than for ones that have random data. In fact, it's why one method used to speed up something like quicksort is to simply do nothing when partitions are fairly small, then when that whole thing completes, run insertionsort on that mostly-sorted list.
edit: What I'm getting at is that the same non-random arrangements don't affect each sort the same way.
Brute-force algorithm might go through all n! permutations and measure it manually.
i love how batcher's odd-even merge sort just *transitions* the values
2倍速で聴くとめちゃくちゃ気持ちいいです!
I love listening to it at double speed.
Ahhh yes it's this time of the year.... youtube strikes again with that algoritm stuff
The algorithm wants to show off its family
Why am I watching sorting videos when I don’t even know math
Quick sort is the one true god... considering its performance and how quick it is to write
Except this is actually the worst case scenario
@@romajimamulo Only if it was choosing the last/first element. In this case, the middle element is the median, so this is pretty effective.
@@Fera-gr5mm That is true.
its cool how with starting reversed some sorts approach a fractal pattern initially
Then there's Odd-Even
Base16 made some sort of rbg boss battle theme intro
@@icebearpl188 some *_sort_*
5:26
Cha cha real smooth
Pigeonhole sort (10:37):
*I AM SPEED*
Pancake sort constantly reversing the already sorted array over and over not knowing any better is such a moment
Batcher's bitonic sort: shakes a bit here and there, decides that it is wrong, Puts it back, and then decides that it prefers the list sorted.
I always found it strange why block sort algorithm seem to, for lack of a better word, carry numbers along while sorting.
That's their internal buffer!
Batcher's Bitonic Sort
"wait, let me merge it in"
"oh wait, there is a problem"
"ok then, i'll reverse it back to fix that problem"
"oh wait, it's the input"
"let's merge it all to-"
"r e v e r s e a n d m e r g e"
I really have to appreciate min heap sort (4:38) taking all the extra time to reform the input then flip it.
5:23
Selection Sorts: Smooth Sort
Looks: *Rough*
They really improved radix base 16 from deafening noises to sorting data. Very creative
5:26 sounds like pulling off a long piece of plastic on a new surface
Gravity sort be like:
1) have values to sort
2) look at them
3) ???
4) profit
A slow one though.
Pigeon hole sort, counting sort and TimSort would have fit.
this is exactly what i was looking for
imagine you had 8 pencils and had to do 125984 comparisons, 585800 swaps and 1171600 writes to main array to sort them from smallest to biggest. thats the bogo sort. (27:01)
Quick Sort is known to be pretty bad in this case, as well as when it’s already pretty much in order. On the contrary, Heap Sort(s) are known to be pretty darn good in every case.
Well, a reversed array is necessarily a heap, so Heap Sorts already have half their work done for them in this case. I imagine they don't do so well if the array is sorted/is close to being sorted, because an array in ascending order is what might be dubbed an anti-heap--no part of the heap is correct.
Quick Sort only struggles because usually, it's programmed to just choose the last item as the pivot, which is bad If that's the biggest/smallest item. If you code it to just pick a random item from the list as a pivot, though, it performs just as well as any other time.
Also, Heap Sort is the worst O(n log n) sort on average, and Merge Sort does better in "all cases." So you're wrong .
@@BigFatWedgeigeonhole? Or even timsort
I finally know how merge sort works! So when there’s a shuffle, every value is what it is just like of place of course. Merge sort works by taking an out of place value and putting it back into its correct place and then there are a couple hundred more values that need to be merged, so when there is half the value of one spike or colour the merge sort will literally merge into 1 whole. In that case being 100 percent. And this pattern is repeated 10 times until the whole thing has been sorted.
odd-even sort: *just turns it around in 3D*
the odd-even looks so sick
11:14 - this reminds me of Metroid Prime title screen for some reason
Great video! I just have a question: how long did it take for all of this to complete?
Me after a gaming session in bed 4:50AM looking at pancake sorts jokes at a youtube video
heap sort is extremely powerful here because it's already all in a heap
Is it me or did Bogo Sort get quite lucky there?
stable quick sort was like trying to start an engine, and it finally starting
Those Deathgrip boys are always innovating
4:30 you would think the min heap sort would figure it out super quick but noooo... 🙄🙄🙄
it's trying is best
Why are you being so rude to min heap sort?
Leave min heap sort alone 🥺
08:08 Visualized merged sort reminds me of 2048 XD
Same
Are you from there future? What's it like in 2048?
So when I play 2048, I'm just being a very slow sorting algorithm?
12:57 "maybe if i put this he- no that dosent work. maybe if i did thi- no that dosent work either. maybe if i jus- oh god now i gotta start all over..."
All hail bogo sort
True, bogo sort can sort any array faster than any other algorithm
@@Choinkus lol
Min Heap Sort: Oops why did i do that lets revert that
Also Min Heap Sort: *reverses the bars*