Quicksort is the new Hello World
blog.rmontanaro.com
Quicksort is the new Hello World
1–10 of 64 posts
Re: Quicksort is the new Hello World
#2Re: Quicksort is the new Hello World
#3For a novice programmer learning their first language, they probably don't understand the quicksort algo and probably have no concept of arrays or any data structure. Visually displaying "Hello World" is very simple and teaches you two basic parts of a language: - Syntax - Printing stuff
On another note, someone learning HTML for the first time will have no reason to do quicksort.
Re: Quicksort is the new Hello World
#4I think your point is valid and of course interesting for programmers, but KR's "Hello, world!" is still relevant for students and novices. Maybe reading/writing on a file would be more useful nowadays, since it does not demand knowledge of algorithms.
Re: Quicksort is the new Hello World
#5Re: Quicksort is the new Hello World
#6Re: Quicksort is the new Hello World
#7It's not like the first thing you're going to do is write out all of quicksort to see if it's easy. You're going to fiddle with numbers an arrays a bit first, particularly if your language has some kind of interactive console. In fact, I wouldn't be surprised if the first thing you do in the language is actually 1+2.
There's quite a bit of syntax you need to learn before quicksort becomes a relevant test.
If you're looking for a good language to build a quick website backend in you probably don't even care about that, you'll care more about having nice ways of passing information around and checking that it has a decent inbuilt sort method.
Re: Quicksort is the new Hello World
#8Re: Quicksort is the new Hello World
#9 qsort :: Ord a => [a] -> [a]
qsort [] = []
qsort (p:xs) = qsort lesser ++ [p] ++ qsort greater
where
lesser = filter (= p) xs
I know nothing about Haskell but I don't think this code implements
the original quicksort algorithm which sorts the input in-place.
Moreover the two-pass of filter over the list and the concatenations
cause unnecessary overhead. Thus, even if the sample code is simple
and elegant, a real-world implementation would surely be a bit longer
than the given example.Re: Quicksort is the new Hello World
#10 qsort (p:xs) = ...
This is not recommended as it results in worst-case behavior on sorted input lists. (Another commentor correctly pointed out that it requires extra memory for the intermediate lists, too.)