#mergesort

vyvy
2026-03-07

Knuth's merge-sort in C. Definitely in the style of mathematician programming.

yodaiken.com/2024/01/24/kuths-

Alfonso Urdanetaaeu@hachyderm.io
2025-01-03

I'm starting to appreciate how useful it is to revisit old code that you wrote and learn from it.

I had previously implemented mergesort in obj-C a few years ago, and looking back at it now, it really hasn't held up to the test of time.

It was correct, but I allocated a ton of unnecessary structures, which is bad when you have recursion and you have a large amount of input data.

Also looking at it now that a few years have gone by, I find that it could be more legible.

This implementation is in C++ and instead of creating data structures willy nilly, I modify the input array in place.

There is a temporary array being created during the merge operation, but I can't get rid of that one.

This version is way cleaner and easier to read.

github.com/aeu/legible-algorit

#programming #cpp #cplusplus #mergesort

Akshat Singhakshatsingh
2024-09-19

β˜‘οΈ Day 8/100: daily question

🟨 Question: 179. Largest Number

Today's question was good and can be answered using a custom sorting function. I did this with 3 approaches:
1. Built-in sort (provided custom key fn).
2.
3.

πŸˆβ€β¬› Check out my where I post all the daily streak πŸ”₯ questions and πŸ† solutions

πŸ”— Solution Link: github.com/akshatsingh1718/lee

πŸ”— My Leetcode Github: github.com/akshatsingh1718/lee

Kuth’s Merge Sort in C
Taken from Knuth Algorithm S mergesort P162-163 Vol 3 Second edition 1998
The major change is that the scratch buffer is not required to be adjacent and there are some changes because C array indexing usually starts with 0.  This is very much how a mathematician write code. You have to remember a larger than usual single letter variables and it has a very clever clockwork
yodaiken.com/2024/01/24/kuths-
#theory #clang #Knuth #mergesort

Roberto Audex β˜‘οΈrobau@mastodon.nl
2022-11-05

OkΓ© vandaag een #ode aan #mergesort, een supersimpele manier van sorteren. #algoritme #simpel #effectief #schoonheid van #eenvoud

* deel je lijst in twee delen. Herhaal voor elk deel tot het 1 of 2 groot is
* voeg de delen samen, waarbij steeds de eerste elementen van de delen vergelijkt. De kleinste mag voorop. Herhaal tot alle delen weer zijn samengevoegd

Supermakkelijk om het werk te verdelen over meedere verdelers en samenvoegers, waardoor dit ook parallel en sneller is uit te voeren.

X Minus T πŸ€¦β€β™‚οΈπŸ‡ΊπŸ‡Έx_minus_t@mastodon.online
2022-06-27
せぢん7of9@qiitadon.com
2019-10-28

#sort
#difference
#mergeSort

What are the different types of merge sort used for?
stackoverflow.com/questions/37

γ“γ‚ŒγŒι•γ†γ¨γ„γ†γ“γ¨γ‚‚γ§γͺさそう

Client Info

Server: https://mastodon.social
Version: 2025.07
Repository: https://github.com/cyevgeniy/lmst