Earlier quoted context omitted.
I love this algorithm (I like implementing type systems) but I always feel a bit naughty when I implement it, as AFAIK it can't be implemented with immutable data structures (not efficiently, at least).
I like implementing type systems Could you expand on this? This is something I've just started reading about. I'd be interested in good resources to use to get started. At the moment I've just started reading TAPL.
Ask HN: What's your favorite elegant/beautiful algorithm?
201–210 of 507 posts
Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#202The 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?
#203I have always liked DBSCAN: https://en.wikipedia.org/wiki/DBSCAN DBSCAN is used for clustering in applications, much like k-means clustering, but in k-means clustering, the number of clusters must be known in advance (hence the k) DBSCAN solves this problem by for every point in the graph checking if a certain threshold of vertices is within a certain radius. If this is the case, it will add these vertices to the new…
[1] http://www.dbs.ifi.lmu.de/Publikationen/Papers/OPTICS.pdf
[2] https://www.cse.buffalo.edu/faculty/azhang/cse601/density-ba...
Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#204Duff's device. Because you will first look at it in disgust, but then you realize how clever it really is. See: https://en.wikipedia.org/wiki/Duff%27s_device
Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#205Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#206Duff's device. Because you will first look at it in disgust, but then you realize how clever it really is. See: https://en.wikipedia.org/wiki/Duff%27s_device
Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#207Earlier 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?
#208Really simple, elegant solution to a hard problem. There are some alternatives that are arguably better in ways, but none are nearly as simple to comprehend