Live data from Hacker News

Quicksort explained IKEA-style

idea-instructions.com

41–50 of 142 posts

Re: Quicksort explained IKEA-style

#41

This surprisingly made this easy to remember for me. Unfortunately, the merge sort instructions doesn't make sense to me, specifically step 3.

It's not a merge sort, it's just a partition. Mark every element greater than your pivot as "move right". Then step 4 marks every smaller element as "move left". Step 5 actually does that.

You don't really need to split that into 3 steps, though it looks a bit more like a real IKEA diagram with the extra steps.

Re: Quicksort explained IKEA-style

#42
post #8

If I didn't know how quicksort works - and I had to learn, since for some reason in FP languages quicksort is typically next after "hello world" - I would struggle to make sense of the pictures, I think. However, it's absolutely brilliant as a memory refresher: it packs so much info in so little space that it's insanely efficient. I imagine it would pair well with a good textbook on algorithms.

Quicksort in FP?

Surely you mean mergesort, that's the classic FP sorting example.

Re: Quicksort explained IKEA-style

#43
I’ve just completed reading all 8 posters on the site. For some reason I find them easier to understand than any written content, code or math. They are all intuitive. It was fun and engaging to solve their notation and meaning they want to convey. The one with AVL trees was the most useful to me.

Re: Quicksort explained IKEA-style

#44
post #19

If we're willing optimize for aesthetic over ability to help understand, I'll nominate demonstration via Hungarian Folk Dance[1] as a candidate for the best medium to depict sorting algorithms, which I first saw during a lecture years ago when the professor pulled up on of the videos to show us in class [1]: quicksort is shown here, but the channel has plenty of others https://youtu.be/3San3uKKHgg

So what is the best algorithm when you have a bunch of people and want them sorted in order of, say, birthday.

Re: Quicksort explained IKEA-style

#45
post #8

If I didn't know how quicksort works - and I had to learn, since for some reason in FP languages quicksort is typically next after "hello world" - I would struggle to make sense of the pictures, I think. However, it's absolutely brilliant as a memory refresher: it packs so much info in so little space that it's insanely efficient. I imagine it would pair well with a good textbook on algorithms.

> for some reason in FP languages quicksort is typically next after "hello world"

Because the recursive implementation is surprisingly straightforward and concise, and more-less demonstrates what the whole paradigm is about. As much as I hate to admit it, it's a good learning artifact.

Re: Quicksort explained IKEA-style

#47
post #44
post #19

If we're willing optimize for aesthetic over ability to help understand, I'll nominate demonstration via Hungarian Folk Dance[1] as a candidate for the best medium to depict sorting algorithms, which I first saw during a lecture years ago when the professor pulled up on of the videos to show us in class [1]: quicksort is shown here, but the channel has plenty of others https://youtu.be/3San3uKKHgg

So what is the best algorithm when you have a bunch of people and want them sorted in order of, say, birthday.

Tell the people with any CS experience they're not allowed to talk, and then let everyone just go for it.

The first part is crucial, because if the group has two or more people exposed to CS courses, they'll invariably start negotiating the optimal algorithm to use while trying to recall the actual implementation, thus preventing any actual sorting from taking place.

Re: Quicksort explained IKEA-style

#49

Earlier quoted context omitted.

You're misunderstanding. They don't explain how to do partitioning at all. Step 3 is just tagging the elements that are above the partition element, which there happen to be two of.

Well, to the extent a picture can explain they say choose at random. That's what the dice shown is about. A random pivot is... fine. It can't solve the worst case perf problem, and it won't ensure high performance for other cases either, but hey you did pick a pivot and this algorithm is often fast enough.

I'm talking about step 5. The elements just magically migrate to the correct position, whereas in the real algorithm they would be moved individually.
Post reply on HN