Live data from Hacker News

Sorting algorithms visualizer

sorting-algorithms.com

31–40 of 41 posts

Re: Sorting algorithms visualizer

#31
This is pretty cool.

I've always found selection sort to be the most intuitive. When I was in school, a professor mentioned that bubble sort is sort of the "easy" sort that people would discover on their own, but I always thought it seemed complicated compared to selection sort.

Selection sort is basically "Find the next smallest item in the remaining unsorted list, and use it as the next value."

Re: Sorting algorithms visualizer

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

Thank you. When I was in college (many decades ago) I just though insertion sorting was it. Then bubble sorts. I did not expect the mental flip I did when we starting researching quick sorts. That changed my perspective on obvious but incorrect assumptions forever.

These visualizers I think can get you there even faster. I just love this stuff.

Re: Sorting algorithms visualizer

#34
post #2

"The ideal sorting algorithm would have the following properties: - Stable: Equal keys aren't reordered. - Operates in place, requiring O(1) extra space. - Worst-case O(n·lg(n)) key comparisons. - Worst-case O(n) swaps. - Adaptive: Speeds up to O(n) when data is nearly sorted or when there are few unique keys. There is no algorithm that has all of these properties, and so the choice of sorting algorithm depends on th…

I went through the list of algorithms in Wikipedia [0] and a reader pointed out that block sort [1] is an interesting case. It has all the best properties listed, except the worst case swaps, which I can't find in Wikipedia.

[0]: https://phunehehe.net/best-sorting-algorithm/ [1]: https://en.wikipedia.org/wiki/Block_sort

Re: Sorting algorithms visualizer

#36

Just for fun: my friend and I 3D printed a model of SelectionSort: https://gfycat.com/HospitableTenderDiamondbackrattlesnake . Each successive layer behind the front one is one iteration of the algorithm. We also made mergesort and quicksort versions, and I'm working on a model of Dijkstra's right now. To be honest the 3D model doesn't really confer a greater understanding of the algorithm as hoped, but it's nice to…

Interesting approach. If this was part of a series and perhaps in a different material + color-mapped (think Shapeways full color sandstone for instance), I could see someone very passionate about algorithms wanting to buy/own/print them.

Re: Sorting algorithms visualizer

#37

This is pretty cool. I've always found selection sort to be the most intuitive. When I was in school, a professor mentioned that bubble sort is sort of the "easy" sort that people would discover on their own, but I always thought it seemed complicated compared to selection sort. Selection sort is basically "Find the next smallest item in the remaining unsorted list, and use it as the next value."

I think you are both right :)

Both seem to me like strategies that you'd intuitively hit upon. I think bubble-sort is a bit more mathsy but a certain type of mind would hit upon it. Because bubble-sort is "Go through the list swapping adjacent items depending on value, Keep doing that until you get no swaps." which is pretty trivial as well.

I remember heap-sort kind of blowing my mind when shown to me. When this kind of topic comes up I am always reminded of D. J. Bernstein's Crit-bit Trees: https://cr.yp.to/critbit.html

Re: Sorting algorithms visualizer

#38

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 :-(.

I am the "guilty" party. sorting-algorithms.com is my site. I have actually been working on a complete refactor of the site and open source the codebase so that others can contribute and add new algorithms. Feel free to reach out - olson {{dot}} ericd {{at}} gmail {{dot}} com

Re: Sorting algorithms visualizer

#39
post #32
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.

Thank you. When I was in college (many decades ago) I just though insertion sorting was it. Then bubble sorts. I did not expect the mental flip I did when we starting researching quick sorts. That changed my perspective on obvious but incorrect assumptions forever. These visualizers I think can get you there even faster. I just love this stuff.

I found out that my usual way of sorting cards as a kid was a variant of quicksort.

This is to sort the cards first into black v. red, then the black cards into spades v. clubs, then the spades into high v. low, then finally sort the low ones by inspection (a kind of insertion sort I guess), sort the high ones by inspection, sort the clubs similarly, etc.

Like most quicksorts, this definitely uses O(log(n)) space as you have a deck of reds, a deck of clubs, and a deck of high spades while you're handling the low spades...

Re: Sorting algorithms visualizer

#40
post #2

"The ideal sorting algorithm would have the following properties: - Stable: Equal keys aren't reordered. - Operates in place, requiring O(1) extra space. - Worst-case O(n·lg(n)) key comparisons. - Worst-case O(n) swaps. - Adaptive: Speeds up to O(n) when data is nearly sorted or when there are few unique keys. There is no algorithm that has all of these properties, and so the choice of sorting algorithm depends on th…

Well, spaghetti sort runs in linear time: O(n) time is spent setting up the device, and O(n) reading out the result. The actual sorting step is O(1) !!!

Unfortunately, it's limited to sorting numbers, and uses O(n) additional space (to be precise, it uses O(n) additional volume).

Post reply on HN