Skip to main content
100%

Visualizing Sorting Algorithms

✓ Published0🌍 Public
Aalexmacy
Last edited Oct 10, 2016
Created on Aug 9, 2016

A visualization compares sorting algorithms by animating 50 shuffled bars in D3 v4 with SVG transitions. Users select Merge, Insertion, Selection, Bubble, or Bogosort, and each step highlights elements being tested or moved in red while counting steps. The code uses D3 scales, timeouts for pacing, and transition-based re-positioning, with shuffle and reset controls.

AI-generated description

JavaScript and D3.js have their own means for sorting and one may never need to use traditional sorting algorithms when developing in JavaScript. So I made this for comparing sorting algorithms in an environment that is more familiar to me.

It's a bit of an off-shoot of the Mergesort series I did here: <a href="http://bl.ocks.org/alexmacy/d6f48eb15d4608c3a71b7681309ebf8c">Mergesort w/ color</a> & <a href="http://bl.ocks.org/alexmacy/9f109c383f8ed21f5f610cb21113ca68">Mergesort animation</a>. I left Mergesort out here because it doesn't work very well with the way I wanted to visualize these. Instead, I used insertion sort, selection sort, bubble sort, and bogosort just for fun.

  • Update 10/9/16: Added Mergesort.
gpl-3.0 Licensed

Similar vizzes