Sorting Algorithms Explained Visually

  Рет қаралды 552,342

Beyond Fireship

Beyond Fireship

Күн бұрын

Пікірлер: 464
@Nanagos
@Nanagos Жыл бұрын
If you think Bogo sort is bad, you haven't heard of miracle sort. This works by checking if the array is sorted, if it's not: check again. You have to wait for some miracle to happen, so the memory is getting corrupted in some way.
@destroreact5706
@destroreact5706 Жыл бұрын
Ah, so I follow Miracle Sort to sort out my real life problems.
@Yipper64
@Yipper64 Жыл бұрын
Its the "are we there yet?" of sorting algorithms. "is it sorted yet?" "no?" "is it sorted now?" "still no?"
@tnvmadhav2442
@tnvmadhav2442 Жыл бұрын
Expecting heat death
@GuyFromJupiter
@GuyFromJupiter Жыл бұрын
Waiting on those cosmic rays lol!
@p3chv0gel22
@p3chv0gel22 Жыл бұрын
At university, we once created a similiar algorithm (funny enough without even knowing that miracle sort was a thing), but based on putting our memory next to a radiation source to basically create our own cosmic rays lol
@joseevb04
@joseevb04 Жыл бұрын
Bogo sort is both the slowest and fastest sorting algorithm. Depending on your luck you can have it sorted at the first try or never, and me personally I like those chances
@MusicBox.Melodies
@MusicBox.Melodies Жыл бұрын
@@mihaimanole2643 I think it is more like 1/infinite if the random sequences are not stored. You might never find the correct sort after a long time but you should get there with infinite time!
@gabriel837
@gabriel837 Жыл бұрын
50% chance every run. the array is either sorted or it isn't
@nixoncode
@nixoncode Жыл бұрын
welcome to the game of life
@KrisKamweru
@KrisKamweru Жыл бұрын
@@gabriel837 biggest brain logic I ever saw 😂
@user-dh8oi2mk4f
@user-dh8oi2mk4f Жыл бұрын
@@MusicBox.Melodies No, each time you shuffle you have a 1/n! chance to have it be sorted.
@maxijonson
@maxijonson Жыл бұрын
The best algorithm I know is the Stalin sort. It simply removes the elements that are not in order. Not only is it an O(n) algorithm, but it also SAVES memory when you run it! It's really great!
@technocraticpolyglot
@technocraticpolyglot Жыл бұрын
Lemme look that up, I was under the impression that Mao sort is the best algorithm ever
@RaefetOuafiqo
@RaefetOuafiqo Жыл бұрын
it is O(n²)
@tnvmadhav2442
@tnvmadhav2442 Жыл бұрын
That would be aladeen sort sir
@hypercrack7440
@hypercrack7440 Жыл бұрын
Doesn't it send them to the Gulag?
@rolandoa.rosalesj.1661
@rolandoa.rosalesj.1661 Жыл бұрын
​@@RaefetOuafiqo It is O(n), because you only need a single for loop, for each element check if the previous element is less than the current one and then yield item, otherwise you continue with the next one.
@regibyte
@regibyte Жыл бұрын
My man out here being sponsored by jetbrains itself. Bravo man 👏🏻👏🏻👏🏻
@anthonyhowell4352
@anthonyhowell4352 Жыл бұрын
Algorithm timestamps: 1:37 - Bubble sort 2:33 - Insertion sort 3:32 - Selection sort 4:11 - Merge sort 5:26 - Quick sort 6:53 - Radix sort 7:54 - Bogo sort
@aarona3144
@aarona3144 Жыл бұрын
I love how you sorted the time stamps for each.
@Gbtx6
@Gbtx6 Жыл бұрын
now we need Beyond Fireship to copy paste this into the description
@jerbear97
@jerbear97 Жыл бұрын
haha insertion
@krissp8712
@krissp8712 Жыл бұрын
Thanks, there was too much prelude and sponsor time.
@jplacsamana9562
@jplacsamana9562 12 күн бұрын
clutch
@MattheousOfficial
@MattheousOfficial Жыл бұрын
Mistake at 4:08 where you say merge sort results in quadratic time when you're talking about selection sort
@ashe_neko
@ashe_neko Жыл бұрын
I heard this too
@thetower8553
@thetower8553 3 ай бұрын
@@ashe_neko I HEARD...something...too
@JSorngard
@JSorngard Жыл бұрын
You should have covered quantum bogosort: 1. Use some quantum source of randomness (e.g. radioactive decay) to shuffle the list. If we assume that the many-worlds interpretation of quantum mechanics is true this will result in one universe for every possible list order. 2. If the list is not sorted, destroy the universe (this is left as an exercise to the reader). 3. The only surviving universe is one in which the list is sorted. This sort is not stable, but this problem can be easily fixed: just use the same randomness source to generate random source code and destroy the universe if the generated code is not a stable quantum bogosort.
@developerpranav
@developerpranav Жыл бұрын
This is like learning the most boring topics in the form of a kindergarten musical math lesson. Absolutely loved it !
@BrokenBuildings
@BrokenBuildings Жыл бұрын
You should have mentioned Quantum Bogo sort, splitting the universe into all possible combinations of the shuffled array and destroying every universe where its not sorted. It has an O(1) time making it the best sorting algorithm
@igorswies5913
@igorswies5913 Жыл бұрын
reminds me of Stalin Sort
@finsflexin
@finsflexin Жыл бұрын
Another good one is sleep sort. It’s just sleeps every value.
@deep.space.12
@deep.space.12 Жыл бұрын
Wouldn't it still require O(n) time to check if the array is sorted?
@Woffieee
@Woffieee Жыл бұрын
@@deep.space.12 Yupp. Anything it would gain through optimization still requires it to itterate through the list atleast once. As in, the shuffling alone requires you to atleast go through the items in the list once. And big O notation only cares about how much each additional item increases the time needed. As in, an algorithm that takes 2n and 20000n would both become O(n) in duration. Just as a an algorithm that completes in 10 cycles regardless of input vs one that completes in 20000000000 cycles would both be considered O(1).
@musilicks
@musilicks Жыл бұрын
@@deep.space.12 nah, cus then we could just do a quantum bogo search and destroy the universes where the sorted list wasn’t selected. Simple.
@diegoalvarez437
@diegoalvarez437 Жыл бұрын
It's funny how my window screen hasn't loaded yet and there's your voice. Thanks for sharing.
@noid3571
@noid3571 Жыл бұрын
I made little markdown explanations in Obsidian for most of these algorithms because our professor had a very questionable teaching method that resulted in like 60% of students confused and clueless. Shoutout to the big brains behind mermaidJS, I wouldn't be able to explain merge sort without your graphs!
@darkarie
@darkarie Жыл бұрын
can you share the explanations?
@bruvhellnah
@bruvhellnah Жыл бұрын
Did you make your own graphs using mermaidJS ?
@noid3571
@noid3571 Жыл бұрын
@@bruvhellnah I just used the top-down graph to illustrate merge sort splitting and forming back together. I'll try to translate the files this weekend!
@noid3571
@noid3571 Жыл бұрын
Sorry guys, I got my hands full. The script is a mess to translate and I just don't have the time but thank you for showing interest. Maybe I'll start writing a new script in English to cover C/C++, JS, and similar stuff and concepts. I guess It will come in handy to someone in the future.
@avaneeshc
@avaneeshc Жыл бұрын
Job interviewers should understand the last line of this video. "So basically, everything you learned in this video is useless on a practical level"
@chrtravels
@chrtravels 8 ай бұрын
I was thinking the exact same thing. Learn this stuff to find a job and the shelf it until time to look for the next job, lol.
@hugazo
@hugazo Жыл бұрын
In pandemic i viewed a LOT of sorting videos, they are mesmerizing in their own way.
@jasonphilbrook4332
@jasonphilbrook4332 Жыл бұрын
It's also worth considering how data might be added to the array causing a need to re-sort. If data is rarely changed, the sort algorithm doesn't need to be most efficient. If data is regularly added or removed, how it's added/removed can be important combined with the sorting algorithm.
@yash1152
@yash1152 Жыл бұрын
yes, i was thinking same
@andreasmahler7967
@andreasmahler7967 Жыл бұрын
wow, my favourite programming youtuber shows videos my buddy from university made a decade ago - never expected that 🎉
@StrangeGamer859
@StrangeGamer859 Жыл бұрын
I like quantumsort. It does nothing but check to see if quantum fluctuations have caused your data to spontaneously sort itself
@GodmanchesterGoblin
@GodmanchesterGoblin Жыл бұрын
The great thing about quantum sort is that somewhere in a parallel universe, your data array already exists in a sorted form, and a parallel copy of you is already using it. 😁
@DrakiniteOfficial
@DrakiniteOfficial Жыл бұрын
Creel's multi part series on sorting algorithms was really excellent and gave a lot of great details, but this was a nice and condense video!
@holdthat4090
@holdthat4090 Жыл бұрын
I think radix sort does extremely well when the input data is massive, like 10M+ values.
@ME0WMERE
@ME0WMERE Жыл бұрын
indeed same with counting sort, although that's for fairly small numbers (counting sort doesn't scale well as the largest number in the array gets large, which is why radix sort exists)
@dealloc
@dealloc Жыл бұрын
But only if 1) it's an array of integers, and 2) requires intermediate sorts to be stable.
@mumujibirb
@mumujibirb Жыл бұрын
@@dealloc i mean, anything can be converted into ints, though it would mean strange code...
@zecuse
@zecuse Жыл бұрын
@@dealloc 1) This can be solved if your data can be transformed into integers in a 1-to-1 correspondence. 2) Only important if you care about positioning.
@1-_-I
@1-_-I Жыл бұрын
I UNDERSTAND NOTHING
@julienwickramatunga7338
@julienwickramatunga7338 Жыл бұрын
Thank you for this video, the sound aspect is really interesting . And the conclusion is gold 😆
@TellyKfsvh
@TellyKfsvh 4 ай бұрын
your videos are a treasure trove for anyone eager to learn something new!
@jsoncarr
@jsoncarr Жыл бұрын
This is timely as I am currently prepping for a tech interview
@mountain3301
@mountain3301 Жыл бұрын
Three sorting algorithms can teach you about practical, theoretical, and then mind-bending sorts. Whether you're preparing for interviews -- at any level -- or curious about the topic, try these: Timsort, a hybrid of insertion and merge sort, may have executed in production more times than any sorting algorithm ever. Variations of it are the standard library for Python, Java, and Rust. It works, and those two are a gentle introduction to sorting. Bucket sort rips up the math you learned, if any, in Timsort (by executing in O(n) time). It can be helpful for interview questions. You might never implement this, but it's a lovely idea. Bitonic sorting is what happens when you take advantage of parallelism -- and the result is awesome! The speed-up is better than linear (e.g. 2 cores running 2x fast), if that's what you were expecting. Look it up!
@juliandesens
@juliandesens 7 ай бұрын
I work at the library and was looking for better ways to sort books! The intro confirmed I was in the right place!
@alexjones420
@alexjones420 Жыл бұрын
Interesting, but which array method will help me center this div?
@Lopolo28
@Lopolo28 Жыл бұрын
BogoSort
@beinyourguard
@beinyourguard Жыл бұрын
flexSort
@xEqualsRandom
@xEqualsRandom Жыл бұрын
gridSort
@GbpsGbps-vn3jy
@GbpsGbps-vn3jy Жыл бұрын
positionFixed sort :}
@JanGottschau
@JanGottschau Жыл бұрын
🏖️
@leyasep5919
@leyasep5919 Жыл бұрын
Because of this kind of videos, I ended up designing my own version of Merge Sort, called YAMS (Yet Another Merge Sort)... It's satisfying.
@jackelhuevo2133
@jackelhuevo2133 Жыл бұрын
The quicksort algorithm implemented in Haskell: qSort :: Ord a => [a] -> [a] qSort [] = [] qSort (x:xs) = qSort small ++ [x] ++ qSort big where small = [a | a
@gyanashekka
@gyanashekka Жыл бұрын
Sponsorship!! Congrats Fireship 🎉🎉
@professornumbskull5555
@professornumbskull5555 Жыл бұрын
Radix Sort, doesn't split in buckets of 10, the general meta is to use a base of 256 and there are two implementations, one with buckets and one with counting, I recommend creel's video on the topic, it's really descriptive.
@codeaperture
@codeaperture Жыл бұрын
6:30. Us chilling to watch it on TV. Thanks fireship You never dissapoint 🔥
@tobias131314
@tobias131314 Жыл бұрын
For Quick Sort at 5:59 he forgot to finish the partition() function with “return partitionIndex;” Great video!
@sjoervanderploeg4340
@sjoervanderploeg4340 Жыл бұрын
I once wrote a sort where I would check the array for consecutive numbers, break if the next is lower than the previous and put all these blocks in a new array. Then run over the array again inserting values at their "correct" position in the new array.
@patcoston
@patcoston Жыл бұрын
If your sorting positive integers, you can use the integer as an index into a counting array initialized to zeroes, then make a single pass to count how many times each number occurs, then restore the array from the counting array. You make 3 passes. Pass 1: Init counting array to 0's, Pass 2: count how many times each value occurs, Pass 3: Rewrite array from counting array. If you have negative integers, find the largest negative number, then use the positive value to offset all of the numbers. When you restore from the counting array, subtract the offset. Finding the correct offset is an additional pass. The offset can work in the opposite direction if the smallest number is very large. Offset the smallest large number to 0. This sort is good when the range of numbers is small. The larger the range, the larger the counting array needed.
@monzerfaisal3673
@monzerfaisal3673 Жыл бұрын
I was always waiting for the day fireship covered algorithms. Did I know I was waiting? No. Was I pleased. Yes indeed
@deftcoleman0552
@deftcoleman0552 4 ай бұрын
Sorting algorithms are satisfying to hear and look at. :)
@rcnhsuailsnyfiue2
@rcnhsuailsnyfiue2 Жыл бұрын
Your Bogosort implementation is even more stoopid than it needs to be 😂 The sorted() function at 8:17 could simply return false immediately, but instead it assigns false - then pointlessly checks the entirety of the rest of the array for no reason! Well done 👏
@TheMR-777
@TheMR-777 Жыл бұрын
RADIX SORT: A Man, who's work doesn't seem useful, but surprises everyone at the end.
@bigjoey1114
@bigjoey1114 Жыл бұрын
Those animations are trippy. It's like watching and listening to a computer think.
@MAGNETO-i1i
@MAGNETO-i1i Жыл бұрын
Quantum Sort is the clear winner, the array is both sorted an not sorted at the same time, so you simply return the sorted array. Order of magnitude is O(-1)
@zaaayn
@zaaayn Жыл бұрын
amazing video as usual!!! by the way at 4:08 you said merge sort but it was the big O notation of selection sort that you were describing
@hashtagPoundsign
@hashtagPoundsign Жыл бұрын
With the sound effects for the sorting algorithms, I am reminded of the NES game “Life Force”, which brings back great memories.
@User-vx2jd
@User-vx2jd 6 ай бұрын
The explanation was on point. you did miss out talking about run time of all sorting methods after selection sort.
@dougpark1025
@dougpark1025 Жыл бұрын
Bucket sort is a solid O(n) sort that everyone should know about. It has limited use cases. Another sorting technique is to take advantage of multiple cores and sort in parallel. A good default choice for sorting is quick sort as it will often be more than fast enough. If you want to have some fun. Ask any programmer how long it will take to sort one million integer or float values. The answer is almost always a surprise. Hint, it is fast enough that when processing tons of data a sort then process algorithm is often a big performance improvement over other options such as tree based systems.
@GeorgeAlexanderTrebek
@GeorgeAlexanderTrebek Жыл бұрын
this was the best video i have ever seen this hour. nice!
@martindaskalov3140
@martindaskalov3140 11 ай бұрын
Oh can imagine it now, senior coming up to me yelling at me, why did i implement this sort when its so slow. And i just turn towards him and say: "I am feeling lucky today".
@JuuzouRCS
@JuuzouRCS Жыл бұрын
Good to know the class I'm currently taking is completely useless as well! Just kidding. Thanks for this awesome video ahead of my exams next month
@naturegirl1999
@naturegirl1999 Жыл бұрын
this brings me back to when youtube randomly recommended a sound of sorting video
@neogruber3031
@neogruber3031 Жыл бұрын
Nice Video! I wish this Video existed, when i hand Algorithms and Data structures in Unitversity...
@duang_duang_bunny
@duang_duang_bunny Жыл бұрын
definitely the best video on sorting ever !
@hpexaltedblade6076
@hpexaltedblade6076 Жыл бұрын
i like how he told us at the end all of these r useless
@alexawunor8853
@alexawunor8853 Жыл бұрын
I love this guy. Nothing can prepare you for the end of this video. 😂
@zdeneksc2895
@zdeneksc2895 7 ай бұрын
Did you hear about CNsort? The Chuck Norris Sort Algorithm (CNSort) is a groundbreaking sorting method that operates on the principle of sheer intimidation. In the world of computer science, algorithms are supposed to logically organize data, but CNSort takes a different approach. Here, arrays don't dare to be unsorted. As soon as the CNSort is invoked, the elements in the array glance up to find Chuck Norris staring them down. Overwhelmed by his formidable presence, the elements immediately line up in perfect order, each one too afraid to be out of place. Efficiency is key: CNSort achieves a sorting time of O(1), because no element wants to waste Chuck Norris's time by being out of order.
@clashclan4739
@clashclan4739 Жыл бұрын
Ending was master piece
@earthling_parth
@earthling_parth Жыл бұрын
4:07 Minor correction to the viewers. Here he's talking about selection sort and not meme sort. After this, there is the merge sort section
@muha0644
@muha0644 Жыл бұрын
My favourite sorting algorithm is `Stalin sort` : Simply iterate over each element in the list. If the current element is smaller than the last, _simply remove it!_ Stalin sort will always produce a sorted array in O(n) time complexity!
@SpektralJo
@SpektralJo Жыл бұрын
These algorithms are all way so efficient! I have written an algorithm with worse time complexity than tree(n). Who doesn't want to make more than grahams number of comparison just to sort two elements?
@TheMR-777
@TheMR-777 Жыл бұрын
RADIX SORT is like a student, who (seem to) doesn't study all year, but outperforms in Exams :)
@xtraszone
@xtraszone Жыл бұрын
JetBrains: Our new Development IDE - Fleet is the future VS Code killer Jeff: I'm gonna destroy the fleet's career JetBrains: *Made him the new business model
@kaushikrishi01
@kaushikrishi01 Жыл бұрын
Bro just got sponsored by Jetbrains 🔥
@B.D.B.
@B.D.B. Жыл бұрын
Insertion sort should be O(N log N). I agree that your implementation of it is O(N^2), but it's very easy to make an insertion into a sorted array an O(log N) operation. Edit: to be clear this can't be done with arrays, because while searching a sorted array is still O(log N) insertion is O(N). So you'd have to copy over the data to a balance binary tree and then copy it back, trading space complexity for time complexity.
@pbtdubey
@pbtdubey Жыл бұрын
4:08 It should be "Selection sort also results in quadratic time complexity."
@Fanta666
@Fanta666 Жыл бұрын
holy fuck a WHOLE NOTHER FIRESHIP CHANNEL?!
@patcoston
@patcoston Жыл бұрын
2:01 The ES6 way to swap two values in an array in one line with no temp variable: [arr[j], arr[j+1]] = [arr[j+1], arr[j]]
@Eazy._E
@Eazy._E Жыл бұрын
Didn’t understand nothing but the animation are just gorgeous
@AchwaqKhalid
@AchwaqKhalid Жыл бұрын
This needs to be updated because of the latest *OpenAi breakthrough* in dorting algorithms 💡
@jerbear97
@jerbear97 Жыл бұрын
_"if you're preparing for a technical interview, these visualizations and audiblizations will absolute change your life"_ Interviewer: "Can you briefly describe to me a Quick Sort?" Me: *_wooOOOP wooOOOP_*
@RubenKelevra
@RubenKelevra Жыл бұрын
0:09 Love how Shellsort is outperforming Quicksort quite dramatically in the example :D
@augustday9483
@augustday9483 Жыл бұрын
Imagine an alternate universe that's identical to our own, except bogo sort always finishes first try.
@helio6839
@helio6839 Жыл бұрын
Radix sort is my favorite
@MerrickKing
@MerrickKing Жыл бұрын
Watching those pancakes getting binned at the end hurt my soul
@codewithguillaume
@codewithguillaume Жыл бұрын
Well, that ESCALATED quickly ! 🤣🤣🤣
@Woffieee
@Woffieee Жыл бұрын
Well, Bogo sort is the theoretically fastest algorithm :) It's also the one that in theory could not be done before the heat death of the universe if you are unlucky enough.
@GoldenEmperor5Manifest
@GoldenEmperor5Manifest Жыл бұрын
Well that went way over my head.
@TANISHQRAJENDRRAAASWAR
@TANISHQRAJENDRRAAASWAR 10 ай бұрын
Great Video Sir , I appreciate you for all the knowledge given by you and for all the efforts that you put in these videos. Sir ,I just wanted to mention one thing that as Books refer to some knowledge and for Indians, book refer to our Goddess Sarawati. So just requesting you not to tear them like this.
@rsflipflopsn
@rsflipflopsn Жыл бұрын
2 years late but appreciating it anyways
@William___cg
@William___cg 4 ай бұрын
The entertaining world of important refund info
@darkfoxwillie
@darkfoxwillie Жыл бұрын
that ending was glorious
@piotralex5
@piotralex5 Жыл бұрын
Time sort - for each element make a thread that will wait element value number of seconds and append the value to the new list
@GamerFigure
@GamerFigure Жыл бұрын
I hate being that guy but mid should be start-(end-start)/2 to avoid Int overflow. Love the videos, you probably know this anyways.
@DinoBaba
@DinoBaba Жыл бұрын
8:55 If schools were always honest while teaching
@Ray-xy1bp
@Ray-xy1bp Жыл бұрын
How about counting sort ? Its the sorting in which you have to increment the elements of the vector that have the given values as its indexes. For example We have the folowing elements : 3 6 2 9 5 1. To sort them, we use a vector V that has all the elements 0 and you have to increment the values V[3], V[6] etc. and then just display the indexes of the non-zero elements
@DUMRATBOY
@DUMRATBOY Жыл бұрын
And my dumbass has watched this twice right now and still doesn’t understand a thing but I’m all for it
@larrytale3401
@larrytale3401 11 ай бұрын
Computer: 'I fear no man, but that thing...' Bogo sort doing random noise on the screen. Computer:'... scares me.'
@shoaibkhalil2036
@shoaibkhalil2036 Жыл бұрын
I loved this video, Jeff plz create a crash course series on youtube on "DATA STRUCTURES & ALGORITHMS" plzZZZ
@aame6643
@aame6643 Жыл бұрын
One niche fact that I think should have been added to the video is that there doesn't exist a comparison based sorting algorithm faster than O(nlogn).
@ggff2269
@ggff2269 Жыл бұрын
If you are haiving trouble learning C , then you must create your owm programming langauage -Fireship
@rounaksen1683
@rounaksen1683 Жыл бұрын
AHH!, Finally pure programming (sorting) 🎵 LoFi 🎧 Music (Kind of).
@Yuuray
@Yuuray Жыл бұрын
omg I found the second fireship channel
@ukraineSpaceman
@ukraineSpaceman Жыл бұрын
The most important phrase is said at the very end of the video. Therefore, you MUST watch the video until the very end. Well, everyone should know sorting algorithms.
@nullternative
@nullternative Жыл бұрын
08:21 bogo sort makes some sick beats, tho.
@Pritam-Youtube01
@Pritam-Youtube01 Жыл бұрын
The radix sort you discussed is not a radix sort it is buckets sort. Radix sort is that where you use count sort on every parts of an elements.
@wolfiexii
@wolfiexii Жыл бұрын
This was awesome, thank you.
@Cinarbayramic
@Cinarbayramic 3 ай бұрын
bogo sort's time complexity is either O(n^n!) or O(0)
@User-vx2jd
@User-vx2jd 6 ай бұрын
I would also recommend you to explain merge heap in your video.
@matka5130
@matka5130 8 ай бұрын
This is brutally COOL
@ynxeita4131
@ynxeita4131 6 ай бұрын
Somehow no one has mentioned bogo bogo sort yet It takes the first two elements of the array and bogo sorts them in the first try It then takes the first three elements of the array (that is, the already sorted first two elements plus the next one) and bogo sorts them in the first try It then does the same with the first four elements of the array, and so on and so forth with the rest of the array If at any point the elements are not sorted after the first try, it starts all over again from the first two :)
@Only_Sleep
@Only_Sleep Жыл бұрын
Putting sorting into the hands of RNGesus sounds good to me
@asdqwe4427
@asdqwe4427 Жыл бұрын
V8 in chrome at least used to be quicksort or some other unstable sorting algorithm. I know because I had to implement merge sort once to get around it.
@pepkin88
@pepkin88 Жыл бұрын
Yeah, me too. Luckily, since ECMAScript 2019, Array.prototype.sort() is stable by the spec.
@sebastjansslavitis3898
@sebastjansslavitis3898 Жыл бұрын
I have an idea for super fast sorting algorithm, it may require a lot of memory, but its always linear, no matter how big is the list. Basically you check value of item and put it in the position equal to its value, than check next and so on.. after you done it with all items you just remove empty spaces and you have perfectly sorted list. zero comparisons. edit: cant handle two identical values
@mdazharuddin4684
@mdazharuddin4684 Жыл бұрын
This is bucket sort (can handle multiple too) This isn't linear but O(max(arr)) Let's say there are only 2 items in your array 1, 10000000. Now you can imagine what will happen 😂
@igorlukyanov7434
@igorlukyanov7434 Жыл бұрын
Your quicksort works in O(N^2) if the data is constructed in special way. Pivot should be random
@olteanumihai1245
@olteanumihai1245 Жыл бұрын
The end was epic.
10 FORBIDDEN Sorting Algorithms
9:41
Ardens
Рет қаралды 925 М.
The Bubble Sort Curve
19:18
Lines That Connect
Рет қаралды 668 М.
СКОЛЬКО ПАЛЬЦЕВ ТУТ?
00:16
Masomka
Рет қаралды 3,5 МЛН
Farmer narrowly escapes tiger attack
00:20
CTV News
Рет қаралды 11 МЛН
Naming Things in Code
7:25
CodeAesthetic
Рет қаралды 2,3 МЛН
8 Data Structures Every Programmer Should Know
17:09
ForrestKnight
Рет қаралды 178 М.
10 Sorting Algorithms Easily Explained
10:48
Coding with Lewis
Рет қаралды 90 М.
Does Deno 2 really uncomplicate JavaScript?
8:55
Beyond Fireship
Рет қаралды 464 М.
Top 7 Algorithms for Coding Interviews Explained SIMPLY
21:22
Codebagel
Рет қаралды 444 М.
I Made Sorting Algorithms Race Each Other
8:24
Green Code
Рет қаралды 224 М.
10 weird algorithms
9:06
Fireship
Рет қаралды 1,3 МЛН
How principled coders outperform the competition
11:11
Coderized
Рет қаралды 1,8 МЛН
СКОЛЬКО ПАЛЬЦЕВ ТУТ?
00:16
Masomka
Рет қаралды 3,5 МЛН