Hacker News new | ask | show | jobs
by nikolaplejic 5547 days ago
I really like the simplicity and the choice of language. I think a comments / discussion section would be useful, for people to ask questions, talk about the ways to make the articles even better and perhaps translate the code to other languages.

All in all - I hope you keep up the good work, solid tutorials like these make it more compelling to keep up with the basics and learn new things from the "CS 101" department.

1 comments

I can't believe I didn't think about comments. I've enabled disqus! Thanks for that, and the other, ideas.
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.

Simple and no clutter.

Do you plan to add more algorithms?

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.

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.

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 (!).
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).

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.