r/Python • u/Sklyvan • Jan 11 '20
Python Sorting Algorithm Visualizer (Using Cocktail Shaker Sort Algorithm)
28
u/tobb10001 Jan 11 '20
I love watching storing algorithms. Do you have a repo with the code?
5
u/nemom Jan 11 '20
I love watching storing algorithms.
What, like... Pickle or tar-bzip2?
3
u/tobb10001 Jan 11 '20
Exactly.
I didn't know storing algorithms are a thing until just a few seconds ago but definitely.
This happens to me to often...
75
u/sxsnyc Jan 11 '20
If anyone is wondering complexity is O(n^2).
23
5
u/ixJax Jan 11 '20
For anyone that doesn't what this means (I didn't until a week or so ago), Tom Scott has a video on it
9
1
u/notneeson Jan 12 '20 edited Jan 12 '20
What is it like weirdly higher efficiency for relatively sorted lists or something?
Edit: Oof it is 2 sided bubble sort. One of the the simplest, least efficient sorts but it does look cool.
1
u/Stelercus Python Discord Staff Jan 12 '20
I assume it uses this sort instead of a more efficient sort because it uses however > and < are implemented for each class, regardless of which types are being compared. That is to say, it's not guaranteed that sort will be sorting numerical types.
10
8
5
u/PancakeLizard69 Jan 11 '20
You mind explains how the cocktail shaker sort works?
0
4
Jan 11 '20
This is almost as satisfying to watch as when the DVD logo finally hits the corner of the screen!
1
1
u/niigupta3008 Jan 12 '20
I am sorry but I have to ask this. I want to do this kind of visualisation too, but I know only basic python. How can I reach this level? What all do I need to know?
1
u/Sklyvan Jan 12 '20
You should know abou Sorting Algorithms (Which is easy), and then know how to use some Graphical Libraries, in this case PyGame.
2
1
1
1
1
1
1
u/69shaolin69 Jan 12 '20
Visualize bob-sort
I forgot the name but it’s the one where you randomize the list and hope for the best
1
0
1
Jan 11 '20
[removed] — view removed comment
1
u/RemindMeBot Jan 11 '20
There is a 1.4 hour delay fetching comments.
I will be messaging you in 14 hours on 2020-01-12 10:40:06 UTC to remind you of this link
CLICK THIS LINK to send a PM to also be reminded and to reduce spam.
Parent commenter can delete this message to hide from others.
Info Custom Your Reminders Feedback
20
u/Sklyvan Jan 11 '20
Since some of you are asking for the source code, I uploaded it to GitHub: https://github.com/Sklyvan/Array_Visualizer