Live data from Hacker News

Quicksort explained IKEA-style

idea-instructions.com

21–30 of 142 posts

Re: Quicksort explained IKEA-style

#21
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

Such a internet classic. I have never once searched for it, yet seen it dozens of times.

Re: Quicksort explained IKEA-style

#23
post #14

This is cool, but missing a LOT of details between steps 4 and 5, which is the meat of the quicksort. Actually, the first and last elements of step 4 would be swapped, which means the order depicted in step 5 is incorrect.

Isn't that more of an implementation detail? I'd guess if you care more about speed than memory it might be faster to just move elements into new array - sequence through old array appending to start/end of new array according to pivot comparison. You'd be moving every element vs leaving some in place with a swap approach, but the simplicity of the code & branch prediction might win out.

I'm pretty sure the swapping is a fundamental part of the quicksort algorithm, not a mere implementation detail. That's the reason quicksort is an in-place algorithm.

Re: Quicksort explained IKEA-style

#25

Step #5 is very much a "draw the rest of the fucking owl" step.

I ignored the arrows and interpreted it as "move all elements lower than the marker in order to the left of the marker, and move all elements higher than the marker in order to the right of the marker". It's not clear, but if you use a bit of intuition you can come to this conclusion. Personally it took me about 5 seconds.

Re: Quicksort explained IKEA-style

#27

I agree, IKEA instructions are great. A bit related are railroad diagrams, like the one of the JSON syntax [2]. I worked on Rubik's cube solving instructions for beginners [1] (for my children initially), but then I found it would be so much better if the instructions are IKEA style. (Then I vibe-coded a Rubik's cube 2D and 3D model, and now I stopped working on this. Something for later.) For the cube, I want to imp…

> Rubik's cube 3D model

Google had a doodle way back when... That let you play the cube on the search page.

I found it hosted here [1] although I'm sure they have a doodles archive. Didn't check it myself but it should be possible to take the JS from that and use it for our purposes.

[1] https://sites.google.com/site/populardoodlegames/rubik-s-cub...

Re: Quicksort explained IKEA-style

#28
post #25

Step #5 is very much a "draw the rest of the fucking owl" step.

I ignored the arrows and interpreted it as "move all elements lower than the marker in order to the left of the marker, and move all elements higher than the marker in order to the right of the marker". It's not clear, but if you use a bit of intuition you can come to this conclusion. Personally it took me about 5 seconds.

Have you ever learnt about Quicksort? If so, it might give you an edge on what to expect.

Re: Quicksort explained IKEA-style

#30

Step #5 is very much a "draw the rest of the fucking owl" step.

I can't tell if this was serious. This really is how a pure Quicksort works, you just recursively apply this same algorithm and the result is sorted. In contrast the initial circles approach can't be recursed to draw the rest of the fucking owl.
Post reply on HN