News for hackers. Stuff that matters.
Re:Simple algorithms by latch on Thursday April 14, 2011 @10:31AM (#2446931)
I can't believe I didn't think about comments. I've enabled disqus! Thanks for that, and the other, ideas.
Re:Simple algorithms by bvi on Thursday April 14, 2011 @06:54PM (#2448793)
Clear, concise explanations. Good job.

A tip: It would be better if you could expand on the "Real World" section, especially when it comes to specific examples (e.g. dictionaries etc). That way, more students would relate to understanding exactly how those data structures are used in practical applications.

Re:Simple algorithms by nrbafna on Thursday April 14, 2011 @10:45AM (#2446998)
Simple and no clutter.

Do you plan to add more algorithms?

Re:Simple algorithms by latch on Thursday April 14, 2011 @10:53AM (#2447034)
I started doing a quicksort, but I didn't feel it was turning out very good. It felt just a bit too complex for the paradigm I was using.

But, I might try again, or find a different approach to represent some slightly more complicated algorithms. Quicksort and some type of Btree would likely be next on my list, if I feel I can do them justice.

Re:Simple algorithms by ggchappell on Thursday April 14, 2011 @11:09AM (#2447101)
I'd do Merge Sort before Quicksort. There's less to say about it, and these days it seems to be edging out Quicksort in the behind-the-scenes-implementation-of-standard-library department.

And, yes, including some kind of self-balancing tree would seem to be a good idea. But how the heck does one discuss such things concisely and simply? I couldn't say.

In any case, nice site.

Re:Simple algorithms by jules on Thursday April 14, 2011 @05:58PM (#2448635)
Another amazing algorithm (or data structure really) is the pairing heap. I just wrote this down, so it's possible that it's not correct, but here he goes:

    data Heap k v = Empty | Heap k v [Heap k v]
    merge Empty h = h
    merge (Heap k1 v hs) h@(Heap k2 _ _) | k1 <= k2 = Heap k1 v (h:hs)
    merge a b = merge b a
    extractmin (Heap k v hs) = (v, foldr merge Empty hs)
    insert h k v = merge h (Heap k v [])
These 6 lines of code provide a heap data structure with amortized logarithmic time for extractmin and constant time insertion and merging (!).
Re:Simple algorithms by ggchappell on Thursday April 14, 2011 @06:50PM (#2448782)
Nice. Never heard of that.

Honestly, though, I don't think such a thing is what this website is aiming at. It seems to be more for the established, widely used stuff.

Still nice, though. (It's cute how, for so many of the "heap" data structures, the merge operation is really all you need to give much thought to. See also Binomial Heap, etc.)

> These 6 lines of code provide a heap data structure with amortized logarithmic time for extractmin and constant time insertion and merging (!).

Hmmm ... maybe. We need to be exceptionally careful in our reasoning about time complexity, when the code uses lazy evaluation (perhaps more careful than people know how to be, yet).

Re:Simple algorithms by taylorbuley on Thursday April 14, 2011 @11:12AM (#2447116)
I'm new to this stuff, and trying to learn fast. This is hands down the best explanation of these concepts I've seen. I suspect you'd do just fine Karl. Keep up the great work.