What algorithm blows your mind? (Reddit compsci)
reddit.com
reddit.com
http://en.wikipedia.org/wiki/Hamming(7,4)
I got interested in these codes because of the problems involved with deep space communication.
http://en.wikipedia.org/wiki/Error_detection_and_correction#...
I remember upon learning it someone went "wow, who came up with that". The prof answered dryly "some genius named Hamming".
And the reasons why it blows my mind:
(1) Knuth called it "Algorithm of the year 1973" (possibly because it beat an intuitive lower bound that he had for a problem I can't remember).
(2) It's relatively new for a "core", first-principles algorithm. Ukkonen's algorithm is from 1995, although there are earlier versions.
(3) This BOOK is largely devoted to the many, many applications of suffix trees: http://www.amazon.com/Algorithms-Strings-Trees-Sequences-Com... It should be required reading for anyone interested in advanced algorithms.
(4) Longest common substring in linear time.
(5) Lempel-Ziv decomposition in linear time.
(6) Longest repeated substrings in linear time.
And too many more to list.
Sort of a probabilistic hash, where you trade space for accuracy. But it's also like a memory function - it can remember if it has seen a piece of data before.
Someone else already mentioned compressed sensing, which expands on some of those ideas. Terrence Tao had a pretty good presentation on the topic: http://terrytao.files.wordpress.com/2009/08/compressed-sensi...
For mor eon the controversy with the Wired article: http://nuit-blanche.blogspot.com/2010/05/compressed-sensing-... http://nuit-blanche.blogspot.com/2010/03/why-compressed-sens...
The new reconstruction solvers: https://sites.google.com/site/igorcarron2/cs#reconstruction
Hardware that are implementing compressive sensing: https://sites.google.com/site/igorcarron2/compressedsensingh...
start from the bottom.
Question 3 here will walk you through the proof: http://bit.ly/cQ03na
For future reference, the unshortened version of his link is: http://www.stanford.edu/class/cs221/handouts/cs221-ps2.pdf
http://www.beyond3d.com/content/articles/8/
It's been discussed here before, and no doubt it'll be cited numerous times in the comments of that reddit post, but it was the first time I'd ever seen such trickery. When I got into low level DSP programming I saw many more examples of clever hacks, but this is the one which sticks in my mind above all of those.
http://en.wikipedia.org/wiki/Sch%C3%B6nhage%E2%80%93Strassen...
At least to me, it seems hard to imagine that multiplying two N-bit integers could be done with less than O(N^2) operations. Schoenage-Strassen lets you do it using O(N log N log log N) operations!
http://en.wikipedia.org/wiki/Lenstra%E2%80%93Lenstra%E2%80%9...
High dimensional work is bloody hard, and this algorithm works amazingly well. I've spoken with Lenstra (one of them) and he's amazingly insightful on these things. He helped to crystalise my understanding of why high-dimensional spheres should be thought of as "spikey," rather than "round."
I'll write it up and submit it. Anyone who cares to email me can get an early version to read, and your feedback would be useful.
Please.
Thanks.
Now, if you look at an n-sphere with respect to orthogonal axes, you find that moving along an axis you get out as far as (1, 0, ... 0) and moving "away" from the axes you only get to (1/sqrt(n), 1/sqrt(n), ... 1/sqrt(n)); but this isn't due to the sphere being spiky -- rather, it's because orthogonal axes are spiky.
it's like a spinning rod, angle doubled and length squared each iteration, with a rod of fixed length and angle added to it each iteration (if the spinner is facing away, it gets shorter, but if towards, it gets longer). Iterate til it goes over 2. If it doesn't then it's in the Set (or maybe you need to iterate more...). [that's my current understanding]
It's pretty clear to me that I can't visualize what it will do over a few iterations (apart from simple cases) - and I sure can't see how it would produce self-similar (ie fractal) shapes. Agreed that that's amazing.
It lets you search a completely unstructured N-item search space using the square root (!) of N queries, not the N queries you'd think were necessary.
Also, the algorithm is so simple that once you know it's possible, and provided you're very comfortable with basic quantum mechanics, it's almost trivial to find the algorithm.
Many algorithms are ordinary genius (eventually you would have come up with it because the problem space dictates the solution), but this one is extraordinary genius (mind-blowingly original and non-obvious). Every time I see it, I'm amazed that it works.
Not enough people know about it! http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.46....
Think about it, every time you get a google map direction/route, one of them is in play.
N = 128 * 3.14159
X = 1000
Y = 0
MOVE(X,Y)
FOR I = 1 TO N
X = X - (Y >> 6)
Y = Y + (X >> 6)
DRAW(X,Y)It seems like they must have sprung forth wholecloth to the inventor in the shower...it's almost impossible to have iteratively developed some of them because even small changes in the algorithms produce terrible results. I remember thinking over and over again, "how the hell could somebody come up with this?"
Searching in comparison looks very engineered, very studied, something that most people could come up with given need, motivation and time.
PHK points out that mapping node n to nodes 2n and 2n+1 will cause cache misses (and often page faults) as we vertically descend the tree. So instead, rearrange the mapping so that the child nodes are often very near their parent node. That way, heap comparisons are usually performed in the same virtual page, which cuts-down on the number of disk accesses the operating system must perform.
It's a heap supporting merging in log(n). While it's usage might not be very common, it is a beautiful data structure.
XC loc1,loc2
XC loc2,loc1
XC loc1,loc2
It took a day of head scratching, and various notes, before I understood that it was a clever way of exchanging the contents of two storage locations, without a third intermediate location. Three consecutive exclusive-Ors.
Approximating the minimum spaning tree weight in subliner time is very unexpected algorithm.
The entire message is coded into a single number and it approaches the theoretical maximum for compression.
Too bad about software patents!
In multi-robot coordination I like the free market system [ http://www.frc.ri.cmu.edu/projects/colony/architecture.shtml ]
And regarding machine learning I like neural nets (MLP), however the algorithms that currently blow my mind are convoluted neural networks (CNNs) and deep belief networks trained with auto-encoders. http://www.youtube.com/watch?v=AyzOUbkUf3M on the 21-minute mark to see it in action.