5 ms·
Weirdly, merge sort might the only sorting algorithm that I learned in school I can actually write without thinking. It's very intuitive and simple, at least to
by jrimbault 7y ago
Weirdly, merge sort might the only sorting algorithm that I learned in school I can actually write without thinking. It's very intuitive and simple, at least to me ?
- skzo 7y agoInsertion sort is very intuitive and simple as well
- wolco 7y agoThe bubble sort just writes itself.
- jrimbault 7y agoDefinitely yes, but I can't write it without thinking like merge sort ¯\_(ツ)_/¯
- klyrs 7y agoWeird flex: I can implement bogosort in my sleep...
- xvector 7y agoI implement cosmic-ray-bit-flip-bogo-sort in every program I write!
- Rebelgecko 7y agoit would be more impressive if you could implement Sleepsort in your sleep For those aren't familiar with sleepsort, it looks something like this, where you use whatever concurrency is available in your programming language of choice to execute the for-loop in parallel for n in array: sleep(n) print(n)
- lenkite 7y agoYou are not the only one. Merge sort and insertion sort are deeply intuitive sorts. Quicksort is not.
- GuB-42 7y agoMergesort is used routinely by people who know nothing about programming. For example, it is used by teachers to sort exam papers by grade. It is one of the rare algorithms that is equally good when run by a computer and by hand.
- elfexec 7y agoMergesort is more intuitive than selection sort, insertion sort, bubble sort, etc? I highly doubt you can write merge sort without thinking about it. And I highly doubt you can write bug free merge sort without thinking about it. Merge sort and quick sort are notorious for bugs introduced by trying to keep track of the indexes. > It's very intuitive and simple, at least to me ? Once you understand mergesort, you have a eureka moment and it all makes sense. But I've never met anyone who thought merge sort was intuitive and simple - especially when learning it the first time.
- jrimbault 7y agoDidn't say I could it do bug free (c-fashion like), but _correctly_ on paper in an algo exam in pseudo ? Yes. Also, for future readers, this wasn't a flex, it was intended as an observation of weird things about brains, I learned many sorting algo (like many readers here) and only merge sort kinda stuck.