Live data from Hacker News

Ask HN: What's your favorite elegant/beautiful algorithm?

news.ycombinator.com

1–10 of 507 posts

Re: Ask HN: What's your favorite elegant/beautiful algorithm?

#3
1. The "Skew Algorithm", aka "DC3", aka Kärkkäinen-Sanders. It uses radix sort in an extremely brilliant way to construct suffix arrays in linear time. I found these explanations helpful (though it still took me some time to digest): http://www.mi.fu-berlin.de/wiki/pub/ABI/SS13Lecture3Material...

2. Fast Fourier transform (FFT). It's another quite brilliant algorithm used for decomposing a function into its frequency components in linearithmic time (among other things).

Re: Ask HN: What's your favorite elegant/beautiful algorithm?

#4
I like Dijkstra's algorithm for finding the shortest path between two nodes in a graph.

It's not so much that it is "beautiful", but it is a remarkably simple algorithm that a human can follow manually. The reason it is efficient is easily understood (it's easy to see how we are able to "finalize" nodes because it's obvious there is no shorter path to that node), and it takes what would otherwise be a complicated task and makes it manageable.

Re: Ask HN: What's your favorite elegant/beautiful algorithm?

#8
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.

Re: Ask HN: What's your favorite elegant/beautiful algorithm?

#9
Myers Diff. It hits the trifecta:

1. An irrefutable improvement over the state of the art.

2. A short paper which can be understood after only a dozen readings or so. I mean really understood, with visualizations and everything.

3. A practical algorithm which can be implemented by nearly anyone (even me).

Post reply on HN