r/java • u/compilerstuck • Dec 03 '20
I Created a Visualization of 20 Sorting Algorithms with Java. Which one do you like most?
https://youtu.be/wGVIiUrESug14
8
u/8bagels Dec 03 '20
that was fun. everytime i was like "ok that was cool im done" the next one was even cooler and worth the stay
12
Dec 03 '20
Isn't this posted like every week?
Also, when I got to quick sort, now I see why they call it QUICK sort! So fast haha
10
4
3
u/coffee-loop Dec 04 '20
Visually, radix was the coolest. But quick sort takes the cake for my programmatic needs!
5
u/AnonymousTaxi Dec 03 '20
The gravity sort reminded me of exploding fireworks. The LSD sort creates a unique and beautiful pattern. The merge sort makes an upside-down heart. Really informative visualization, thanks
2
u/jrootabega Dec 03 '20
I'm having a hard time telling if I'm in /r/java or /r/outerwilds, both of which I've been frequenting lately.
2
2
u/jrootabega Dec 03 '20
Why did you do bogo sort differently?
3
u/og_amigo Dec 04 '20
Because of how bad of a sort it is, it would have taken years to handle the amount of items all the other sorts were handling, so it needed less in order to fit it into the video.
1
u/jrootabega Dec 04 '20 edited Dec 04 '20
I don't think that makes any sense.
Oh OK, I usually think of bogo sort as something that is slow enough that you satisfy yourself it's slow and then don't care about it completing. This is the most recent time I've thought about it - https://www.youtube.com/watch?v=kPRA0W1kECg&t=5m18s
Didn't realize the sort actually completed here - it was a little hard to notice the sorted arrangement of colors with so few dots.
Even so, I'd be interested in seeing bogo sort on an array with the same size as the other sorts. It would probably look pretty.
1
u/og_amigo Dec 05 '20
What bogo sort does is randomize the array until it gets it right, so it would likely not complete the sort, considering the array has 15,000 items, for years, unless you got very lucky.
2
2
u/agentoutlier Dec 04 '20
Iām rather surprised that radix sort did kind of shitty.
In the mid 90s when I was in high school I wrote a bunch of sort algorithms in C and radix was super fast.
1
u/Mandelvolt Dec 04 '20
I'm also surprised l that radix sort isn't the fastest in most of his videos.
2
2
2
2
2
Dec 03 '20
I am a bit disappointed, that there was no monkey sort. But i guess the vid would have taken way longer if you would have added monkey sort.
1
1
1
1
-7
0
Dec 03 '20
[deleted]
15
u/compilerstuck Dec 03 '20
There are 1500 Elements in an Array, visualized in a circle (red to blue)
Every Element has its own colour.When 2 Elements are swapped:
- They change their position in the circle
- They get closer to the mid of the circle if they are more far from their original positionSo.. original position means furthest away from mid (sorted)
4
u/ShameSpirit Dec 03 '20
I assume the radial coordinate represents the error in that point's current placement?
1
u/krad213 Dec 04 '20
This visualisation is good to show performance, but it doesn't show how the algorithm work.
0
u/jrootabega Dec 03 '20
Doesn't that mean that we shouldn't really expect any red dots near the "upper right center?" Or maybe it's just hard to tell red from dark red from bright purple when in dot form?
0
0
5
u/n4nart Dec 03 '20
This is soo beautiful can you please specify what did you use for the visual part FX or Swing?