No video

Cycle Sort

  Рет қаралды 139,140

Timo Bingmann

Timo Bingmann

Күн бұрын

Visualization and "audibilization" of "Cycle Sort" algorithm.
Sorts a random shuffle of the integers [1,100] using Cycle Sort - en.wikipedia.or...
The algorithm is an in-place transposition-based sorting algorithm, which always requires only the minimal number of writes to the array.
It achieves this by calculating the rank of each element, and swapping it into the correct position.
The animation is slowed down during the video to give you time to see how the algorithm works.
More information on the "Sound of Sorting" at panthema.net/20...

Пікірлер: 147
@razerage1
@razerage1 7 жыл бұрын
1:20 MUST... COMPARE... EVERYTHING!
@jsceo
@jsceo 4 жыл бұрын
XDDDDDD
@brahamaggarwal1800
@brahamaggarwal1800 2 жыл бұрын
No it actually this sorting algorithm actually doesn't compare like that, it has time complexity of O(n) and space complexity of O(1), why don't you look this up, I'm sure you won't regret studying this.
@garlicxi
@garlicxi 2 жыл бұрын
@@brahamaggarwal1800 this comment was 4 years ago
@chickenbobbobba
@chickenbobbobba 3 ай бұрын
@@brahamaggarwal1800 ik this comment is 2 year old now but its n^2 according to wikipedia
@BendenDrijver
@BendenDrijver 9 жыл бұрын
From 1:25 - end: [sorting intensifies]
@irgendwerausbayern1999
@irgendwerausbayern1999 7 жыл бұрын
Ben den Drijver XD
@GeometryDashSwietymiki
@GeometryDashSwietymiki 6 жыл бұрын
I only come for this comment
@cnflx
@cnflx 6 жыл бұрын
Ludicrous Speed!
@infitium7246
@infitium7246 3 жыл бұрын
faster... gasp... faster... yes... [can't speak anymore]
@Juurai
@Juurai 8 жыл бұрын
What, no base drop? I really anticipated a base drop there in the end
@mistymysticsailboat
@mistymysticsailboat 4 жыл бұрын
the end sweep was the drop
@maurolionelmipianoyyo11
@maurolionelmipianoyyo11 2 жыл бұрын
@@mistymysticsailboat right
@TheRaineWitch
@TheRaineWitch Жыл бұрын
*bass
@MoolsDogTwoOfficial
@MoolsDogTwoOfficial 6 ай бұрын
The base dropped so hard, we went from hexadecimal to tenary.
@ilex_occulta
@ilex_occulta 9 жыл бұрын
I never knew sorting algorithms oculd make really trippy music.
@KevinSiebert
@KevinSiebert 8 жыл бұрын
Listen to bogo sort
@isaiasolivares8254
@isaiasolivares8254 8 жыл бұрын
That was stressful near the end
@thebottlewithoutalix2806
@thebottlewithoutalix2806 6 жыл бұрын
1:24 self destruct activated
@AvindraGoolcharan
@AvindraGoolcharan 10 жыл бұрын
Seems super inefficient, but it sounds pretty!
@steamcastle
@steamcastle 10 жыл бұрын
well it is not speed that is the point, of this sort, it is doing the minimum writing.
@steamcastle
@steamcastle 9 жыл бұрын
***** that is up to you, but why wouldn't you ever want to use this?
@sugarfrosted2005
@sugarfrosted2005 9 жыл бұрын
steamcastle Because he likes destroying hardware? Or perhaps he meant he wouldn't want to use it, but begrudgingly would in the right circumstance.
@steamcastle
@steamcastle 9 жыл бұрын
***** I think you are missing a word or two.
@markhesse4510
@markhesse4510 5 жыл бұрын
@@steamcastle Anti-SSD-fail sort
@csmcstrsshd
@csmcstrsshd 6 жыл бұрын
This is what the Predator's self-destruct sequence should have looked like
@HalcyonMeteor72
@HalcyonMeteor72 4 жыл бұрын
This sort algorithm becomes heavy when the number is too large. (It took two and a half days to do it with the maximum number (2048)) * This is the number of days if you continue to work without changing the speed from 1.00 ms.
@SomeDudeInBaltimore
@SomeDudeInBaltimore 5 ай бұрын
I literally just tried to implement this on en ESP32 with an SD card for sorting a flat file database of elements. After 10 or so elements it starts taking a long, long time. I'm gonna have to put SOME of the elements into memory and sort them there, this really isn't going to work for my project which requires a responsive UI on a OLED screen.
@Baldlick
@Baldlick 3 жыл бұрын
Put an element where it belongs and swap it for the element that took its place Put that element where it belongs and swap it for the element that took its place And repeat until you find a element the lowest, go to the element that is next to it and do the same thing Like a cycle
@smaybius
@smaybius 2 жыл бұрын
There are no swaps. What's in blue is just the item being held in aux memory
@Baldlick
@Baldlick 2 жыл бұрын
@@smaybius Oop- I was new to sorting algorithms at that time
@lenselement9020
@lenselement9020 8 жыл бұрын
Yeah I'm making a dubstep remix of this
@bonedoggle
@bonedoggle 5 жыл бұрын
how's that dubstep remix coming along
@NoriMori1992
@NoriMori1992 4 жыл бұрын
Did you post it on SoundCloud?
@selftaughtsurgeon
@selftaughtsurgeon 3 жыл бұрын
Chill guys, it takes a while. Wait a few more years.
@MajorMandyKitten
@MajorMandyKitten 7 жыл бұрын
I don't get why it needs to check the sorted elements.
@anonymoususer9837
@anonymoususer9837 6 жыл бұрын
Shemy Djent I'm guessing it's because it doesn't remember they were sorted. This algorithm minimizes writes, and remembering an item is in the right place would take a write to memory? I'm not sure.
@nanchoparty
@nanchoparty 6 жыл бұрын
1:35 Sounds like the sound of a charging laser from an old Sonic the Hedgehog game
@theLuigiFan0007Productions
@theLuigiFan0007Productions 8 жыл бұрын
This is one crazy algorithm. Never seen anything like it.
@MASTERO400
@MASTERO400 7 жыл бұрын
You could optimize a lot through adding an additional dynamic array which would be the 'workspace' instead of accessing the original one this whole time.
@PeterAuto1
@PeterAuto1 7 жыл бұрын
That would be against the purpose of this Algorithm. This Algorithm has the minimal write Access. The Blue bar should be in the Register
@jhanfc
@jhanfc Жыл бұрын
​@@PeterAuto1 ann n
@oh_finks
@oh_finks Жыл бұрын
this sort is basically bubblesort, but without the efficiency
@yusufsahinyzs
@yusufsahinyzs 7 жыл бұрын
that beat-drop-build-up tho
@douggale5962
@douggale5962 8 жыл бұрын
What if aliens see this?
@Xeverous
@Xeverous 8 жыл бұрын
bad things gonna happen; especially if they find bogo
@Obstagoon862
@Obstagoon862 7 жыл бұрын
+Xeverous What if they're friendly?
@Xeverous
@Xeverous 7 жыл бұрын
Derp Nerd Then I will be happy cuz I love maths
@tylerian4648
@tylerian4648 6 жыл бұрын
Xeverous They'll think that BOGO sort is a secret program for unlocking the secrets to the universe or something based on the fact we still have it despite all the other sorters we have and switch all their programs to run BOGO sort thus guaranteeing our survival of first contact.
@want-diversecontent3887
@want-diversecontent3887 5 жыл бұрын
Doug Gale Well, if they saw this through our broadcasts or terrestrial contact, they would be advanced enough to understand arrays. They need to see any sorting algorithm which requires comparisons and isn't just a bogo or bozo sort. EVEN BUBBLE SORT WOULD KEEP US SAFE.
@EdwardNavu
@EdwardNavu 6 жыл бұрын
It''s reverse selection sort but you're forbidden to rewrite the same element the second time.
@markhesse4510
@markhesse4510 5 жыл бұрын
Because a second rewrite of the same element would degrade the SSD unnecessarily.
@joshzimmerman
@joshzimmerman 8 жыл бұрын
Whew. I feel like I need a cigarette after that ending.
@drone_better7757
@drone_better7757 6 жыл бұрын
No. Don't advocate drug use in a harmless video.
@stardustreverie6880
@stardustreverie6880 5 жыл бұрын
@@drone_better7757 so anyone talking about cigarettes in any context is advocating drug use now? I feel like I need a cigarette after reading that.
@kyleinwis
@kyleinwis 10 жыл бұрын
Never seen this before. But I wouldnt ever want to use it, I dont think.....
@steamcastle
@steamcastle 9 жыл бұрын
why not?
@IlersichProductions
@IlersichProductions 9 жыл бұрын
steamcastle It's extremely slow.
@steamcastle
@steamcastle 9 жыл бұрын
it depends on your system. if you have a system where reading is fast but writing is slow, this sort has the lowest number of writes of any sort.
@IlersichProductions
@IlersichProductions 9 жыл бұрын
steamcastle True, but that's not a very common situation. EEPROMs (what I think you're referring to) are almost never used as RAM. It would probably be faster to use radix or merge sort then write it to the EEPROM.
@steamcastle
@steamcastle 9 жыл бұрын
Laersico well what about flash.? but really the place I see it being useful is if you need to sort objects in the real world. with a robot that is. it would be be done with the sort in the time it takes to move just one objects. for data on a "computer" a bubble sort or Cocktail sort often okay as it can be done just a couple of lines of code.
@jonnynik7626
@jonnynik7626 7 жыл бұрын
HOUSTON WE HAVE A PROBLEM
@PointyGorman
@PointyGorman 10 жыл бұрын
What an amazing algorithm
@raymontdabizach
@raymontdabizach 6 жыл бұрын
is this what it feels like to chew 5 gum?
@gray6209
@gray6209 3 жыл бұрын
this will sound strange but these help calm me down when im having a panic attack
@Obstagoon862
@Obstagoon862 6 жыл бұрын
1:35 What are you doing? Everything's already sorted!
@7GtwNYkHYs
@7GtwNYkHYs 6 жыл бұрын
YOUR DOSE OF AUDIO VISUAL SUBLIMINAL PROGRAMMING IS COMPLETE, HUMAN. CARRY ON. 🤖
@dr_banks
@dr_banks 6 жыл бұрын
The ending made me think that there was a jumpscare inbound. I nearly had a heart attack.
@lmartinson6963
@lmartinson6963 3 жыл бұрын
Listening to this while sleep deprived is terrifying for some reason.
@ItsDaKoolaidDude
@ItsDaKoolaidDude 6 жыл бұрын
Oh dear God it's following the booklet instructions...
@ferociousfeind8538
@ferociousfeind8538 6 жыл бұрын
Uhh, the ehole thing's already sorted? You only need to compare the non-green tiles tho?
@raffimolero64
@raffimolero64 6 жыл бұрын
NEEDS OPTIMIZATION
@ENCHANTMEN_
@ENCHANTMEN_ 6 жыл бұрын
Yeah, it should keep a list of indexes that are already sorted. Although maybe it's I'm case there are elements with equivalent values? IDK
@anthlagr.1816
@anthlagr.1816 6 жыл бұрын
(1:25 and ahead) >Engine starting
@kevnar
@kevnar 2 жыл бұрын
My dogs started howling in dismay by the end of this.
@RammusTheArmordillo
@RammusTheArmordillo 7 жыл бұрын
This is DEFINITELY alien music.
@AnonEMoose-mr8jm
@AnonEMoose-mr8jm 6 жыл бұрын
Best sounding sort
@meh23p
@meh23p 6 жыл бұрын
Sounds really eerie...
@AAAAAAAAAA42
@AAAAAAAAAA42 9 жыл бұрын
daft punk
@cinaedus8781
@cinaedus8781 5 жыл бұрын
You guys know which super Mario level this sounds like
@judef
@judef 3 жыл бұрын
you know what this reminds me of? The scrumptious taste of pomegranate.
@Ambipie
@Ambipie 2 жыл бұрын
Is this for a tiny system that can't think so well?
@dnaroseandthewolves
@dnaroseandthewolves Жыл бұрын
It's when writes are expensive
@maxispeeltspellen4892
@maxispeeltspellen4892 6 жыл бұрын
1:39 sounds like an alarm tho
@chasenplayz
@chasenplayz 7 жыл бұрын
sounds like metroid music
@whiteeye2121movalik
@whiteeye2121movalik 3 жыл бұрын
hypnotizing
@markhesse4510
@markhesse4510 5 жыл бұрын
"How to sort data on a SSD without destroying the storage cells"
@Ztenam976
@Ztenam976 7 жыл бұрын
1:43 DROP
@LocalGoober10
@LocalGoober10 3 жыл бұрын
The end sounds like a self destruction sequence alarm.
@Scrolte6174
@Scrolte6174 Жыл бұрын
Sounds like an alarm.
@DiptiranjanHarichandan
@DiptiranjanHarichandan 9 жыл бұрын
How did make the sorting graphic ?? i mean using bars n sifting them ......
@asifkamboh3188
@asifkamboh3188 6 жыл бұрын
great example
@builderdex
@builderdex 6 жыл бұрын
Scotty! Get more power to the warp drive. And somebody turn off that DAMNED alarm!
@shiningarmor2838
@shiningarmor2838 6 жыл бұрын
You'll tear the bloody ship apart, Jim!
@LudwigvanBeethoven2
@LudwigvanBeethoven2 5 жыл бұрын
1:24 about to drop da base
@Andrescarmona767
@Andrescarmona767 7 жыл бұрын
FeelsGoodMan Clap
@clobre_
@clobre_ 3 жыл бұрын
1:40 *firetruck noises*
@whiteeye2121movalik
@whiteeye2121movalik 3 жыл бұрын
i was sure m laptop was about to blow up towards the end
@machineball
@machineball 4 жыл бұрын
me an anime fan, and i find myself watching this at 2:21 am
@MM-ny7dv
@MM-ny7dv 5 жыл бұрын
1:40 SELF DESTRUCT IN 3..2..1
@joshyeins
@joshyeins 8 жыл бұрын
Please can someone explain how it works? Im not stupid, I just haven't studied maths in years and stumbled upon this.
@tdelfino2509
@tdelfino2509 8 жыл бұрын
+MadHatter It works based on the idea that an item is in the right position if everything before it is smaller and everything after it is larger. (1) Start by examining the first item. (2) Count how many items to the right are smaller than the current item; this is the rank. (3) If the rank is greater than 0, take the item that number of spaces ahead and swap (the previous element is now in the correct position). (4) If the rank is 0 (no items are larger, current item is already in correct position), move to the next item. (5) Repeat from step (2) until the end of the list is reached. In this video, the blue highlight represents the swap point for the end of the iteration. As items to the right are examined (red), each one that is smaller moves the blue highlight forward. When the end is reached, the proper position for the current item is found.
@wcodelyoko
@wcodelyoko 5 жыл бұрын
It sounds like an horror movie.
@HollowDesert
@HollowDesert 6 жыл бұрын
So what are these sorting algorithms for?
@omzldn6472
@omzldn6472 5 жыл бұрын
What do the different colours that aren't red or white mean?
@PoltergeistHC4L
@PoltergeistHC4L Жыл бұрын
Ligth blue finds the place for dark blue, wich then sitches place and "placing" it correctley = green. Becouse it swithced place the light blue must then find the new place for the new dark blue, and thus the cycle continues, I think this is a method of a mechanical spinning disc sorting.
@wengel_eth
@wengel_eth 5 жыл бұрын
Cycle Sort is the best sorting algorithm change my mind.
@laramads5101
@laramads5101 5 жыл бұрын
Bogo sort is adorable and tries its best dammit. Slow sort and stooge sort have anxiety and paranoia, and cycle sort tries just a little too hard. best sorting algorithm family ever.
@wengel_eth
@wengel_eth 5 жыл бұрын
@@laramads5101 I think you made the other guy delete his comment haha.
@starduststriker8792
@starduststriker8792 3 жыл бұрын
mother 4 final boss theme
@princeofexcess
@princeofexcess 8 жыл бұрын
I am really interested... Who watches these and why? (Is it to visualize sorting algorithms as a software engineer. Is it for mathematicians to get inspiration? I really dont understand who the main audience for this is)
@iPiehax
@iPiehax 8 жыл бұрын
People who are learning sorting algorithms.
@58VintageSunburst
@58VintageSunburst 8 жыл бұрын
Its for relaxation.
@HitLuca94
@HitLuca94 7 жыл бұрын
I am actually doing a master degree in ai and i really only like to see this algorithms visualized, nothing more
@ponocni1
@ponocni1 7 жыл бұрын
Random bored people with lots of curiosity, that just wanna know something more random.
@lorenzorossi2000
@lorenzorossi2000 7 жыл бұрын
It's to watch how certain algorithms behave: In our school they teach us algorithms but we learn only code not visualizing much. Those videos help us visualize how they behave and it helps us to remember the code
@judef
@judef 3 жыл бұрын
this makes me hungry
@stallion8499
@stallion8499 8 жыл бұрын
does anybody understand whats even happening?
@aeonsoforigin
@aeonsoforigin 7 жыл бұрын
Why did it continue after it sorted N-1 elements in place?...that means the remaining element must already be sorted.
@Sneakydud2
@Sneakydud2 8 жыл бұрын
Its a teleportation device
@alexeyborodulin1781
@alexeyborodulin1781 8 жыл бұрын
alien invaders take control
@magicschoolbus8417
@magicschoolbus8417 7 жыл бұрын
*bogosort intensifies*
@egoisto656
@egoisto656 5 жыл бұрын
Why does this sounds like animal collective
@izzrainy7410
@izzrainy7410 6 жыл бұрын
squak
@PG-20
@PG-20 3 жыл бұрын
Seems very inefficient
@dustunmalone7816
@dustunmalone7816 Жыл бұрын
🟪🟩🟫⬛️⬜️🟥🔲🔳🟧🟥🟥🟥🟥🟥
@FMcheeky
@FMcheeky 5 жыл бұрын
これはスッキリしない
@Ivan-qb7kc
@Ivan-qb7kc 7 жыл бұрын
WTF?!
@Froncusiek
@Froncusiek 7 жыл бұрын
Oh, another useless sorting algorithm
@ponocni1
@ponocni1 7 жыл бұрын
Read desc, Its made to minimalize how much write process it needs to sort and how fast that sort is is kinda unrelevant. This thing would be great for flash disks and ssds, since they got limited write cycles.
10 FORBIDDEN Sorting Algorithms
9:41
Ardens
Рет қаралды 841 М.
15 Sorting Algorithms in 6 Minutes
5:50
Timo Bingmann
Рет қаралды 24 МЛН
Can This Bubble Save My Life? 😱
00:55
Topper Guild
Рет қаралды 64 МЛН
7 Days Stranded In A Cave
17:59
MrBeast
Рет қаралды 75 МЛН
Little brothers couldn't stay calm when they noticed a bin lorry #shorts
00:32
Fabiosa Best Lifehacks
Рет қаралды 18 МЛН
I Made Sorting Algorithms Race Each Other
8:24
Green Code
Рет қаралды 105 М.
CYCLE SORT
1:31
Ulaş Kasapcopur
Рет қаралды 1,9 М.
How To Read Russian In 9 Minutes (Seriously)
9:10
Life of Yama
Рет қаралды 955 М.
What happens if you connect Windows XP to the Internet in 2024?
20:35
Visualization of Radix sort
7:02
udiprod
Рет қаралды 52 М.
HOW TO WIN MONOPOLY EVERY TIME
10:59
What's What
Рет қаралды 4,1 МЛН
I Tried To Beat Minecraft Backwards
18:53
Contraption8or
Рет қаралды 1,3 МЛН
The Bubble Sort Curve
19:18
Lines That Connect
Рет қаралды 533 М.