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.
Ask HN: What's your favorite elegant/beautiful algorithm?
211–220 of 507 posts
Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#212https://en.wikipedia.org/wiki/Paxos_(computer_science) It took me days/weeks of processing to understand it (and appreciciate the problem(s) it solves).
Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#213Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#214Earlier quoted context omitted.
It is absolutely an algorithm in the sense of "a set of rules to be followed". I think you mean that it doesn't guarantee an optimal solution. That just means it's a heuristic algorithm, same as simulated annealing is a heuristic algorithm for solving optimisation problems.
Nope. An algorithm has to be effective. You can find pathological cases for k-means such that it will never converge on anything useful. So if you set your termination case to be convergence it will never terminate and if you don't then it will never be effective.
Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#215Bloom filters are interesting. A bunch of different hashes as kind of fingerprint that make search fast but with caveats: negative answer is negative, positive answer might be negative.
Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#216Less than 10 lines of code to create a piece of art.
Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#217I always push my devs to really study the Bittorrent protocol. The elements of the protocol are all fairly easy to understand, but it's gorgeous to see how elegantly it solved a social problem rather than a computational problem. The tit-for-tat and fast-finish protocols are incredibly graceful ways to create virtuous cycles in a social/technical hybrid, and replaced very real vicious cycles in previous protocols. Va…
An Introduction to Kademlia DHT & How It Works
http://gleamly.com/article/introduction-kademlia-dht-how-it-...
Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#218The Gale-Shapley Algorithm to solve the "Stable Marriage" problem. 2012 Nobel Prize in Economic Sciences for its wide-ranging use in medicine, education, and resource allocation. It's fairly easy to implement a basic version of it, feels intuitively obvious once explained, and has been applied to everything from organ transplants to student placement in elementary schools. Really, any place you have two groups where…
Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#219Binary 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...
Regarding "very simple" - as I recall from some book, first bug-free implementation appeared only after several years after invention / initial description of the algorithm. From wikipedia: "A study published in 1988 shows that accurate code for it is only found in five out of twenty textbooks" ( https://en.wikipedia.org/wiki/Binary_search_algorithm ).