Live data from Hacker News

Sorting algorithms visualizer

sorting-algorithms.com

11–20 of 41 posts

Re: Sorting algorithms visualizer

#12
post #3

This is interesting, I'd never thought about considering the number of swaps that an algorithm does. It seems like low swapping algos should be better in multithreaded environments due to less locking.

There can be a lot more to consider than just the number of comparisons (which a lot of sort algorithm texts concentrate on if they fixate on one thing) which can have an effect on which sort is better for a given circumstance.

If an exchange is very expensive then you might prefer an order of magnitude more comparisons in order to reduce the number of exchanges needed. The structure of your data makes a difference too especially if you are trying to sort in-place with little or no extra memory: an exchange by insertion is very efficient with a linked list (just rearrange the links) but can be very expensive with a fixed array (shifting the last element to the front involves moving every other element up one).

Sometimes the comparison might be rather expensive at times: if you are trying to sort data stored over many distributed nodes then you need to be careful to pick an algorithm that can constrain itself as much as possible to the local data on each node.

Concurrency can be a big issue even if not running on distributed data: some algorithms are much more "lock heavy" than others.

And even for a single threaded local only sort on modern CPUs cache use can make a big difference: an algorithm that you intuit should run quickly because it can move objects very far at each step might not be all that good because it much more rarely sees cache hits when looking at data than one that works on smaller local chunks in its inner loop.

No one method fits every use: sometimes you want an exchange class sort, sometimes insertion class, sometimes , ...

Re: Sorting algorithms visualizer

#14

This is a really nice page! It would be even nicer if there was some way to find out who made it and/or how to contact the author(s); and/or how and whether one can add more algorithms (e.g. I'd love to see timsort and introsort). As it is, this site seems to be completly anonymous. Which is of course a valid choice by the author(s), but IMHO quite sad :-(.

Not completely anonymous. http://who.is/whois/http://www.sorting-algorithms.com

https://github.com/ericdolson

Re: Sorting algorithms visualizer

#19
post #15

One of my favorite sites that i usually share with my students is: http://www.cs.usfca.edu/~galles/visualization/Algorithms.htm... Many algorithms and nice visualizations.

Agreed. This was a nice resource to use while I was taking a data structures and algorithms class.
Post reply on HN