Hacker News new | past | comments | ask | show | jobs | submit login
Sorting Algorithms Revisualized (imgur.com)
281 points by mdturnerphys on Oct 27, 2017 | hide | past | favorite | 36 comments



This brings back something I had all but forgotten. The first ever assembly language program I got to run was a bubble sort implementation that sorted the text characters on the screen. I painstakingly typed it in from a book on 6809 assembly language programming. I didn't know what it was going to do, so I was blown away when I saw how it could actually manipulate and sort characters in video memory right before my eyes.


The problem with colorblindness is a common one. I saw the post in question and it was just a typical rainbow color scheme, and it never even occurred to me that they might cause trouble for color blind users.

Is it possible to map the RGB colorspace onto a colorblindness safe colorspace? This would be a cool feature that I feel Web Browsers could provide to be more accessible for their users


You might find this interesting, the story about the new default colormap in matplotlib 2.0

It's about more than colorblindness -- about how represent a steady linear scale with color and how to keep it faithful in grayscale.

http://medvis.org/2016/02/23/better-than-the-rainbow-the-mat...


There is the cube-helix approach, but I suspect you're thinking about something else.

The linked talk about the creation of the viridis colour map[0] actually spends a good ten minutes on explaining colour theory, and makes it look very simple in the process.

About ten minutes in it shows the "perceptual colour space" of a typical non-colourblind person. A few minutes later it shows the color spaces for people with various types of colourblindness.

Perhaps one could project one perceptual space into the other in a way that more-or-less preserves the original information, but essentially with more banding?

[0] https://www.youtube.com/watch?v=xAoljeRJ3lU



> Is it possible to map the RGB colorspace onto a colorblindness safe colorspace?

Multiple variant options are built into Android.

Even color blindness aside, the rainbow color map is bad because of the relative overrepresentation of green among other things. See https://www.research.ibm.com/people/l/lloydt/color/color.HTM


If you're referring to what I think you're referring to, those are just emulations for development use, i.e. you can use them to figure out if your app is accessible for people with those colorblindnesses.


> Is it possible to map the RGB colorspace onto a colorblindness safe colorspace?

Sure, grayscale is safe. I don't think it's possible without losing some information.


Sorry, why not just gradient from white to black?


Because colors with components that result in the same intensity will be identical. Think a shade of red and a shade of blue that wined up the same shad of gray. The fact that both were distinct colors is lost.

By limiting the transformed colors to those a person is blind to, you limit the amount of information loss.

I think the ideal place to tackle this issue is as near to the display as possible. A screen purpose-built for the color-blind would be best, but redshift-esque software would do the job just as well.



Not really. Colorblindness affects 0.001% of the population. (but that's wikipedia)


From wikipedia:

"Red–green color blindness affects up to 8% of males and 0.5% of females of Northern European descent."

That's around 4% of the population, not 0.001%.


That's red-green color deficiency, not "colorblindness" as in "I only see grayscale". The english wikipedia says it's about 0.025% of the population [0]. So I'll take that instead of the german one.

[0] https://en.wikipedia.org/wiki/Achromatopsia


> That's red-green color deficiency, not "colorblindness"

from The Free Dictionary:

"Noun. 'color blindness' - genetic inability to distinguish differences in hue"

and from https://en.wikipedia.org/wiki/Color_blindness

"Color blindness, also known as color vision deficiency, is the decreased ability to see color or differences in color.[2]

[...]

Red–green color blindness is the most common form, followed by blue–yellow color blindness and total color blindness.[2] Red–green color blindness affects up to 8% of males and 0.5% of females of Northern European descent.[2]"

Your very specific definition of colour blindness (i.e. 'colour blindness' = 'Achromatopsia') does not seem to be represented in the colloquial usage. Thus the parent of you is correct.


He's not. I don't know why people assume that red-green color blindness/deficiency is equal to colorblindness. Because it's not. There is no need to save characters or be imprecise on this matter. Sure it may be used. But it's still a wrong usage. If you mean red/green say it. Otherwise it is not clear what is meant, and of course I'll assume total color blindness. Although, in german there are two words for this. "Rotgrünschwäche" and "Farbenblind". The first one is red/green, the other one total. People usually don't use both for different meanings.


> But it's still a wrong usage.

There is no such thing as "correct" in language, except in Europe where one or two countries have official standards (e.g. France). For English there is only colloquial usage and maybe the Oxford English Dictionary (Which 99% of the time agree with each other). Both of them state that "Color-blindness" is the accepted term referring to all conditions related to color deficiency.

> People usually don't use both for different meanings.

And welcome to English, where we have one word that encompasses any color-deficiencies, and we call that word "color-blindness".

It is used as a blanket term for any color-deficiency, including but not exclusive to red-green, yellow-blue, and monochrome vision. I can tell you now, that as a native English speaker, if you were to talk about "color blindness" to another native speaker, they will not assume that you mean Monochromacy specifically. In fact, they are more likely to think that you mean red-green color-blindness, since that is more common than Monochromacy. In any case, it is extremely rare to find usage that matches yours.

(Literally. The first reference in the Oxford English Dictionary is to Protanopia, not Monochromacy: https://en.oxforddictionaries.com/definition/colour-blind)


Well, those 4% hold true if there is an equal amount of males and females of Northern European decent. But yeah, should be aroune 4%.


Although I also imagine with all the new electronic-ink monitors, there might be a larger need for grayscale-compatible colors. Also regular grey-scale printing.


I have protanomally and saw the original post, and I didn't even think about the rainbow map. It was very informative still. However, the pixels are so much easier to follow in the new version! Guess I am so used to being "deprived" of full information that I didn't even realise what I was missing!


Wouldn't the gif for Bogosort be humongous, because it has to try all possible permutations? Maybe this article is just using random noise gif instead for size concerns.


Bogosorting an array of the given size would take much longer than the lifetime of our sun. You think the author might not have given us the full gif depicting that sort? I don't know!


right, that is my point! I made my comment because I feel the author was being misleading about just how much a "long time" and by falsely suggesting that the animation he put up for it was real and not just random noise.


I feel like he made a joke.


> "This is a very important sorting algorithm, though it takes a long time to sort this data."

The author is clearly being tongue-in-cheek here and making a bit of a joke!


Would be nice to see a visualization that took into account real computer performance concerns such as caching, branch prediction, and instruction-level parallelism.


Ahh, this is so much better. I'm red-green colorblind but I'd have thought that using the "rainbow" color wheel gradient wasn't very intuitive to people with normal color vision either. Given two hues it isn't intuitively obvious which hue is "greater" (as is evident from the fact that people have to memorize the order of the colors in a rainbow), plus the scale wraps around perceptually (as the term "color wheel" implies) so it isn't even a proper total order.


Here’s a good writeup on the benefits of using the viridis palettes for data visualization, using examples in R: https://cran.r-project.org/web/packages/viridis/vignettes/in...


Every time something like this comes up, I think of Mike Bostocks wonderful Visualizing Algorithms[0]. The essay is not comprehensive, but shows more than just sorting. It also deals with sampling, and with maze generation. Truly worth your time.

[0]: https://bost.ocks.org/mike/algorithms/


Neat, made my own a few weeks back, It's in JavaScript tho so can't deal with huge datasets, oh and there's sound.

- https://caspervonb.github.io/toneofsorting/ :-}


One thing to remember with these is that they don't show the speed of the sorting algorithms because the movement of numbers is animated. If they are written further away, the square of that color travels further, which takes time.


try: http://schoolnotez.com/

click on the computer science page to see the various sorting algos.


Really cool! Is the code available publicly?


It's not OP's, but I made a this [0], and the code is available here [1]

[0] https://franciscouzo.github.io/sort/

[1] https://github.com/franciscouzo/franciscouzo.github.io/tree/...


Thank you!


Why is imgur so magnified on my desktop? It's horrible. I can't even see an entire gif at one time on my screen.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: