News for hackers. Stuff that matters.
Re:Simple algorithms by baddox on Thursday April 14, 2011 @01:58PM (#2447770)
I like the writing style and simplicity of presentation. I would recommend putting some thought into the order and organization of the articles. Perhaps you should have "main" articles about data structures, then sub-articles about the algorithms that are relevant to them (e.g. "binary search" could be under "arrays," "heapsort" and "priority queue" operations under "heaps," etc.). Obviously, it's a challenge to choose the order and organization of topics and subtopics—it's essentially the task of developing a curriculum.

If you plan on doing some tree/graph algorithms, perhaps you could have a brief introduction to the topic by talking about trees and graphs in general, then proceeding by discussing heaps, simple binary trees (which can branch off into more advanced topics like the various balanced binary trees), and so forth.

As a side note, I think binary trees are a great visual way to introduce the concept of asymptotic running time in a more accessible/pragmatic (albeit less rigorous) way, by showing that the more balanced a binary tree is, the fewer steps it will take on average to find an element (approaching the best-case of log base 2 of n). You can show how a worst-case unbalanced binary tree degrades to a linked list.

Re:Simple algorithms by latch on Thursday April 14, 2011 @07:43PM (#2448911)
I struggled with the ordering. I wanted to do linear searching first, because i thought it was the most fundamental and important to understand for the other stuff. And then I didn't want to do binary search right away because it's more complex.

I'd like to add more, but as I said in another comment, when I started doing quicksort, it didn't feel right. I'd likely need to build a different UI paradigm to represent more complicated algorithms. Same with a btree, I really want to go over it, but that seemed like a ball of UI hurt. Might still try to tackle it though.

Re:Simple algorithms by trobertson on Friday April 15, 2011 @07:54AM (#2450217)
One thing I noticed was that you use an array in your linear search example. The example is good, but assumes that the reader knows what an array is. Perhaps you should switch the linear search and array positions, so that you know the reader will know what an array is before using it in your examples?
Re:Simple algorithms by nikolaplejic on Thursday April 14, 2011 @10:20AM (#2446889)
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.

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.
Re:Simple algorithms by jcampbell1 on Thursday April 14, 2011 @12:44PM (#2447479)
A fantastic set of articles. I do think that tutorials in general obsess over sorting too much. Rather than expanding this with dozens of sorting algos, it would be nice to see a treatment of trees and graphs. Lay the foundation for someone to understand search trees, huffman coding, A*, etc.
Re:Simple algorithms by tszming on Thursday April 14, 2011 @11:03AM (#2447070)
Re:Simple algorithms by baddox on Thursday April 14, 2011 @01:45PM (#2447738)
Does the author ever claim what language the code is in? Sure, it looks like JavaScript, but he could easily have just borrowed JavaScript's function syntax (which is easily readable to anyone who's used virtually any imperative programming language) for his pseudocode.

The potential "bug" you pointed out has nothing to do with the algorithm being taught, and is an implementation detail that's irrelevant for this application.

Re:Simple algorithms by jws on Thursday April 14, 2011 @11:30AM (#2447186)
Yes, but if you are using binary search on a list with 2^52 elements…
Re:Simple algorithms by maggit on Thursday April 14, 2011 @12:08PM (#2447331)
Did you mean 2^32? That I could understand. 2^52 looks entirely random to me.
Re:Simple algorithms by tsewlliw on Thursday April 14, 2011 @12:40PM (#2447463)
the implementation on the site is in JavaScript, where everything is 64-bit floats. I'd guess 52 of those bits are mantissa.
Re:Simple algorithms by jws on Thursday April 14, 2011 @01:21PM (#2447637)
Alert! There is an error on the internet. The source I used for Javascript mantissa size was wrong. It said 53 bits, I knocked one off to avoid the addition overflow, but that source must have counted the sign bit.

IEEE doubles only have a 52 bit mantissa, so you need to keep that array under 2^51 elements. Call it 2 quadrillion to be safe.

Re:Simple algorithms by Apocryphon on Thursday April 14, 2011 @02:31PM (#2447881)
I've seen many of these "intro to algo" presentations and I have to say this is one of the best. I suppose the Web 2.0 minimalist style helps to facilitate understanding very well. Perhaps there could be sites that could provide math tutorials in the same way.
Re:Simple algorithms by mfonda on Thursday April 14, 2011 @12:52PM (#2447519)
I really like this idea, thanks for putting this up. I think it would be nice to additionally split it up into a data structures section and an algorithms section.
Re:Simple algorithms by damncabbage on Friday April 15, 2011 @06:09AM (#2449990)
This site is great! I love the way latch has presented the examples with each concept. (I would've begged for something like this ten years ago when I was still in highschool.)

I would love if he could take this further and, say, cover graph algorithms in the same way the Linked List was done here.

Re:Simple algorithms by tcarnell on Friday April 15, 2011 @04:47AM (#2449875)
Nice! Great idea for a site - actually, I kinda had a similar idea when I registered "algolution.com" - the idea being to have a library of algorithms AND people can add implementations in different languages and of course vote up which are the best.

In addiation I had thought to add a 'live run' feature so that you could actually run 1 or more algorithms together and compare performance/memory usage etc!

hmmm... if we defined an API for running a piece of code and returning results, we could build a series of independant web applications that could run sandboxed code in different languages live on the web...

Re:Simple algorithms by nickconfer on Thursday April 14, 2011 @11:13AM (#2447124)
I had this same idea the other day. Glad to see someone made this. I hope you add more content in the future.

From a teaching perspective I think it would be great to see the math behind this as well to get the worst case scenerio.

Re:Simple algorithms by giltotherescue on Thursday April 14, 2011 @11:52AM (#2447263)
Yes! Thank you for putting this together.
Re:Simple algorithms by f1gm3nt on Thursday April 14, 2011 @02:38PM (#2447911)
http://www.youtube.com/user/AlgoRythmics By far the best. Is it possible to implement something like this?
Re:Simple algorithms by thurn on Thursday April 14, 2011 @01:06PM (#2447579)
Is this open source? Nice visuals.
Re:Simple algorithms by latch on Thursday April 14, 2011 @07:39PM (#2448904)
I'll probably post the source on github sometime over the weekend.
Re:Simple algorithms by latch on Friday April 15, 2011 @08:44AM (#2450331)
Re:Simple algorithms by olragon on Thursday April 14, 2011 @01:27PM (#2447669)
you are my sunshine
Re:Simple algorithms by Rickasaurus on Thursday April 14, 2011 @12:59PM (#2447553)
Oh look, it's 200 level CS algorithms.
Re:Simple algorithms by pavel_lishin on Thursday April 14, 2011 @01:28PM (#2447671)
Oh no, not a free resource with controllable animations that show you step by step what's happening in the code!