Visualization and Comparison of Sorting Algorithms

preview_player
Показать описание

Visualization and comparison of 9 different sorting algorithms:
- selection sort
- shell sort
- insertion sort
- merge sort
- quick sort
- heap sort
- bubble sort
- comb sort
- cocktail sort

The algorithms are used in 4 types of input data:
- random 0:01
- few unique 1:07
- reversed 2:08
- almost sorted 3:38

Audio: Drop It - Silent Partner
Рекомендации по теме
Комментарии
Автор

I loved watching the heap sort at "almost sorted" 3:38. It's like "Fuck this, I do my own thing!" and completely re-does the thing.

Huntracony
Автор

Watching Bubble sort at almost sorted is like watching a 6 year old trying to finish a puzzle with one piece left but instead of putting it in place it eats the piece.

digitsstuff
Автор

if it wasn't for bubble sort... this video could have like 1 minute

karffiol
Автор

Quicksort is generally the fastest general-purpose sorting algorithm, but the naïve implementation, where the chosen pivot is the first item in your sub-list, causes it to collapse into the worst-case scenario of O(n²) if the list is already sorted or reverse sorted; with a very slight performance loss (usually only one or two instructions per recursion), this is solved if you choose the midpoint as the pivot instead, as is shown in the video. It also tends not to be the best algorithm to use for small lists (less than 10 items or so) due to the amount of overhead required. You might also notice that it instantly sorts the reverse sorted case, but it cannot verify it until it goes through all log n recursions.

Cocktail sort (never heard it called that until now) is essentially a bi-directional bubble sort.

WaterCrane
Автор

I like how in almost sorted, heap sort immediately starts unsorting itself; Good job heap sort.

SomeTomfoolery
Автор

Just think, if the inventor of the bubble sort had named his "quick sort, " how fast his algorithm would have run.

greg
Автор

Pretty sure I'm faster than Bubble sort

RoboBoddicker
Автор

I feel empathy towards bubble sort, the little guy takes his time, but gets there in the end. You did good!

llamallama
Автор

3:39, Three!!!! Two!!!! One!!!!

Insertion Sort: Done

pspful
Автор

Bubble sort...



DO IT !
Just DO IT

Don't let your dreams be dreams
Yesterday you said tomorrow
So just DO IT
Make your dreams come true
Just DO IT !
Some people dream of success
While you're gonna wake up and work hard at it
Nothing is impossible

You should get to the point
Where anyone else would quit
And you're not going to stop there
No, what are you waiting for?

DO IT !
Just DO IT
Yes you can
Just DO IT
If you're tired of starting over
Stop giving up!

BlackOldDragon
Автор

bubble sort can be slow in the long run, but on small sets, it can be faster than quick sort, it is all a matter of finding a proper size for the problem. In fact its usage is the optimization of sorting when the problem becomes too small for a more advanced routine to be efficient.

melficexd
Автор

Damnit Bubble Sort, get your shit together.

christianbuhl
Автор

Bubble is like "omg guys... slow down, you are too fast". :D

swagbaby
Автор

Random (0:02)
1. Quick sort
2. Shell sort
3. Merge sort
4. Heap sort
5. Comb sort
6. Insertion sort
7. Selection sort
8. Cocktail shaker sort
9. Bubble sort

Few Unique (1:09)
1. Quick sort
2. Shell sort
3. Merge sort
4. Comb sort (same time with 5?)
5. Heap sort (same time with 4?)
6. Insertion sort
7. Selection sort
8. Cocktail shaker sort
9. Bubble sort (.. )

Reversed (2:09)
1. Quick sort (GAS GAS GAS)
2. Shell sort
3. Merge sort
4. Heap sort
5. Comb sort
6. Selection sort
7. Insertion sort
8. Bubble sort (YeA!1!1)
9. Cocktail shaker sort (bruh)

Almost Done (3:40)
1. Insertion Sort (GAS GAS GAS)
2. Cocktail Shaker sort (certified speedrun)
3. Quick sort (screw life (change my mind))
4. Shell sort (im always in ur shadow -_-)
5. Merge sort
6. Comb sort
7. Heap sort (screw me)
8. Bubble sort (at least im not last owo)
9. selection sort (🥲🥲🥲)

astro_cat
Автор

I needed a sorting algorithm for my program that would let me draw transparent objects from farthest to nearest, and it was this video that solidified the decision to use Quicksort. The ability to batch textures and reduce the number of draw calls for opaque objects was an unexpected bonus. Just look at the _few unique_ scenario and imagine that you have four different textures. Quicksort blows everything else out of the water.

DrunkJackal
Автор

Can somebody just pop the bubble already and put it out of it's misery. This is too depressing to watch.

MultiDevan
Автор

Why the heck do I still use bubble sort

Mr_Shmallow
Автор

I used the pivot mecanic from Quicksort to sort three decks of cards.
I am now in love with Quicksort.

tailbonetailbone
Автор

Hehe, cool. When I started programming as a kid and I didn't know any algorithms and I once needed to sort numbers, I implemented Selection Sort, because that's how I thought you naturally put numbers in order. Put the smallest on the beginning, then the next smallest next etc. But some of these more advanced algorithms are so pretty. I really like Heap Sort for example, even if it's not used much in real programs. I just think the algorithm is really nice. And I guess even though this algorithm isn't normally used for sorting, the heap structure it's based on is very useful for other things too.

rosebuster
Автор

- Random 0:01 Quick, Shell, Merge, Heap, Comb, Insertion, Selection, Cocktail, Bubble
- Few Unique 1:07 Quick, Shell, Merge, Heap, Comb, Insertion, Selection, Cocktail, Bubble
- Reversed 2:08 Quick, Shell, Merge, Heap, Comb, Selection, Insertion, Bubble, Cocktail
- Almost Sort. 3:38 Insertion, Cocktail, Quick, Shell, Merge, Comb, Heap, Bubble, Selection

- Small Data Set?

emmanuelrodriguez
welcome to shbcf.ru