Diffie–Hellman. I know that cryptography can get much fancier and more clever, but Diffie–Hellman took a concept my intuition told me was impossible and showed that it's possible in a really simple, elegant way. Learning about it was the first time I realized how beautiful the math behind computer science is. It's also a great insight into just how fundamental the concept of computational complexity is.
And here is an elegant explanation of the Diffie-Hellman protocol https://www.youtube.com/watch?v=YEBfamv-_do
Ask HN: What's your favorite elegant/beautiful algorithm?
341–350 of 507 posts
Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#342Binary search. Very simple, incredibly powerful; can search on data or math function. It's the basis for other CS concepts. JS implementation: https://gist.github.com/netgusto/90c8e0e7019a832cbf95eac58e1...
Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#343Previous discussion: https://news.ycombinator.com/item?id=2657277
Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#344Earlier quoted context omitted.
It's also critical for factoring prime numbers and SETI signal intelligence processing. Truly a gem.
Factoring prime numbers?
https://math.stackexchange.com/questions/977955/is-there-a-w...
My experience with this is from using Prime95 two decades ago as part of a distributed computing project to factor Mersenne prime numbers
https://en.wikipedia.org/wiki/Prime95 | https://www.mersenne.org/
Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#345Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#346Exponential backoff: I don't know if this is a published algorithm. Basically, background processes need to keep retrying an operation until it succeeds. (Make an API call to a server, upload a file, ect, ect.) If the retry interval is too small, you can DOS the remote server. (Server returns a 5xx error because there's a corner case that hits a defect.) But, if the retry interval is too large, your background proces…
The summary (from the article) is that:
sleep_time = random_between(0, min(2 ** retries, max_sleep_time))
so that retries are "spread across" the delay window.Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#347It was ugly, I had used 8 for loops, each running for 8 iterations, but, I still felt awesome when it worked. Before this, I had written only lab programs. Next, I applied the backtracking algorithm to solve Sudoku recursively, and that's how it all began. I entered the world of algorithms.
I know it's just one form of brute force algorithm, maybe doesn't even count as one, and is not that elegant, but, it will always remain my favorite.
Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#348a. Solving the nut/bolt matching programming challenge with Merge sort.
b. Backtracking e.g. finding the ordered pair of braces
c. Not to mention the various tree/ graph walk problems
d. I screwed my Google interview last round not knowing the problem could be easily solved topological sort
Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#349K - means clustering, which I learned about recently. For non-machine learning folks, this algorithms helps in grouping relevant items together. As a practical, using this algorithm you can segment your customers based on their purchase history and interests. The actual algorithm is very simple, imagine a lot of points on the 2D plane and each of them represent customers, whom you want to segment/cluster. Now, chose…