3 ms·
Wow this page is very cool! I recommend clicking these four boxes: - quick sort - merge sort - custom sort (this naive algorithm) - bubble sort
by chubot 5y ago
Wow this page is very cool! I recommend clicking these four boxes:
- quick sort
- merge sort
- custom sort (this naive algorithm)
- bubble sort
Then click “start”.
And then you can clearly see the difference side by side, including the speed of the sort!
Quick sort is quick! Merge sort is better in the worst case but slower on this random data.
- smusamashah 5y agoWhat you are seeing isn't speed but the iterations. If you see the source, I am drawing at certain location in the loop. Sometimes when swap happens, sometimes afterwards. More than speed you are seeing the steps.
- chubot 5y agoI think that is what I mean -- when there are fewer steps in the sort, then the visualization completes faster. So if you visualize two sorts side by side, it's obvious which ones completes faster, and that corresponds to the algorithm's speed, right?
- smusamashah 5y agoEach draw step is one draw call. For example in some algos where there isn't a clear swap operation I draw the whole array in one step, which may or may not reflect all operations that happened before that draw call. https://xosh.org/VisualizingSorts/sorting.html#IYZwngdgxgBAZgV2gFwJYHsIwgUwO4DK6ATsgBTDHEA0MAJscHgJQwDeAUDFJiMtjAC8MSsQB0AGxwQA5sgAWAbi5wSMMlP6pBABkUxUAHgj7UAajOtOMeGo05+AK137Hx1xatcbqOOtEA2qgAujCGIlQBjsFeNjYgeMAADhRUtKi0jszKcSKJqPwMTKk0MADM6dRZOTYAvt55wAX0jHgltABM2d71NkxNha3tMACM3TD1tUA https://xosh.org/VisualizingSorts/sorting.html#IYZwngdgxgBAZ... You can change the detail level slider while its running and see how it changes the animation. At level 1 (higher level) this and insertion are same.