Live data from Hacker News

Rainbow Sort Visualisations

ljs.io

11–20 of 53 posts

Re: Rainbow Sort Visualisations

#11
post #7

Earlier quoted context omitted.

Thanks :D This was just a quick hack a year or so ago, am open to enhancing it though - feel free to post any suggestions over at https://github.com/lorenzo-stoakes/Rainbow-Sort/issues :)

Add bogo sort and gnome sort.

All suggestions, even for these highly efficient sort algorithms, are welcome ;-)

Re: Rainbow Sort Visualisations

#12

Really nice. The examples suggest to me that a lot of algorithms would be more accessible to people if they could be visually represented in some way. The timing is important -- the slowness of the bubble sort compared to the quickness of the quick sort gives one an immediate sense of why one would generally want the latter over the former.

Often it has to do with speed of implementation and a data set that is small enough for negligible difference. There is also an issue of whether the algorithm keeps duplicate ordering intact.

Re: Rainbow Sort Visualisations

#14
post #5

I'm seeing waaaay too much stuff happen all at once for quicksort. Frankly, most visualizations give you an inkling as to the logic behind an algorithm, but quicksort just sort of pops the field into the correct order in a blur. Another classic sorting algorithm to visualize is heapsort.

Try turning down the block size (the value that defaults to 20), that will make it far slower - try 5. I know that isn't too obvious, but this was something of a quick hack :)

Yeah, the problem is it just sort of "happens" without me being able to understand what's going on behind the scenes. For instance, all of a sudden half the screen is slightly more sorted, but I have no clue what went into getting it that way, even though it took more time to do so.

Re: Rainbow Sort Visualisations

#16
post #5

I'm seeing waaaay too much stuff happen all at once for quicksort. Frankly, most visualizations give you an inkling as to the logic behind an algorithm, but quicksort just sort of pops the field into the correct order in a blur. Another classic sorting algorithm to visualize is heapsort.

Try turning down the block size (the value that defaults to 20), that will make it far slower - try 5. I know that isn't too obvious, but this was something of a quick hack :)

I looked through the code, I see why quicksort is such a blur now, and I don't see an obvious way to fix it. Since you are in a sense, benchmarking these algorithms.

One way to do it might be to allow the user to set the timeout in your defer function.

Setting the timeout to 1 second lets the user observe each run of your algorithms. You can see the partitioning behaviour a bit better like that.

Side note: this code is pretty. I should learn coffeescript.

Re: Rainbow Sort Visualisations

#19
post #18
post #17

Reminds me of this: https://www.youtube.com/watch?v=kPRA0W1kECg

Dude, don't tempt me to add sound :P

Sound is cool at first but then gets way annoying. I had never heard of radix sort, 0 comparisons.

Are you planning on adding more sorting algorithms like mergesort?

Re: Rainbow Sort Visualisations

#20
post #18

Earlier quoted context omitted.

Dude, don't tempt me to add sound :P

Sound is cool at first but then gets way annoying. I had never heard of radix sort, 0 comparisons. Are you planning on adding more sorting algorithms like mergesort?

Yeah, I am kidding - don't worry I won't, I can imagine that getting pretty irritating :P

I did this as a quick hack on a whim about a year ago (was a visualisation I wanted to see but couldn't find one quite like this), I am pleasantly surprised by the positivity on this (I kinda posted it on a whim), so I think I will probably hack on it again :-)

It's tempting to code up a whole bunch of sorting algorithms, merge and heap sort are definitely high on the list.

Post reply on HN