Live data from Hacker News

Quicksort explained IKEA-style

idea-instructions.com

71–80 of 142 posts

Re: Quicksort explained IKEA-style

#71
post #42

Earlier quoted context omitted.

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

quicksort, e.g. the haskell[0] example is quite well known. Problem is, it's not real since it doesn't work in place defeating the whole point. [0] https://qnikst.github.io/posts/2020-10-18-quicksort.html

It really shines if you want a shortcut on a whiteboard interview, though.

Re: Quicksort explained IKEA-style

#75
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.

Am I alone in that I always felt like mergesort was easier to explain (and the O(n lg n) behaviour was easier to prove)?

Re: Quicksort explained IKEA-style

#76
post #2

This is so cool! Not only is the design similar, but just like the real IKEA instructions, I can't understand them! This is as realistic as it gets.

I kind of get it, but just like Ikea instructions, you start second guessing yourself, then you realize, its BACKWARDS after you flip back 5 pages in when something doesn't fit.

Re: Quicksort explained IKEA-style

#77
I was confused by step (3). The right pillar doesn't need to move right because it's already to the right of the chosen pillar.

I guess what it's trying to say is just "mark it as needing to be to the right", and then do the opposite in (4) and then (5) is where things actually move.

Re: Quicksort explained IKEA-style

#79
post #20

Earlier quoted context omitted.

> since for some reason in FP languages quicksort is typically next after "hello world" How does FP handle the random selection?

There's no problem with randomness in FP? You could use a monad/external state for an OS-level RNG, or define a purely functional PRNG

It's usually quicksorting a linked list, where a random pivot, median of three, etc. are terrible for performance.

(Merge sort is of course the natural sort for lists, but qs is like 2 lines of Haskell so it gets demoed for being clever)

Re: Quicksort explained IKEA-style

#80
My first thought was that it would be explaining Quicksort using an Ikea warehouse as a metaphor, to show how different algorithms suit different constraints.

As for the actual Ikea-style instruction pamphlet... I suspect that making it was very helpful for the author. But I don't think the result would have helped me as a novice. It took some work for me to understand the diagram, and I've used Quicksort.

Post reply on HN