3 ms·
One of my favorite problems is solving median based on a stream of data that you can replay, but only using, something like 3 variables of the same type of the
by codezero 6y ago
One of my favorite problems is solving median based on a stream of data that you can replay, but only using, something like 3 variables of the same type of the data (which I think needs to be integer) from the book Numerical Recipes in FORTRAN.
It’s to optimize finding the median from a tape drive in the 70s, but the technique is pretty cute.
You make a guess at the median, then basically sum how many are over, and under that value, then guess again until you have an even split.
It’s also a problem I like to use to nerd snipe people, because why not.
Check my work, because it’s been a long time since I worked with FORTRAN and I could have just remembered incorrectly :)
https://github.com/jonlighthall/nrf77/blob/master/mdian2.f https://github.com/jonlighthall/nrf77/blob/master/mdian2.f