User Tools

Site Tools

This is an old revision of the document!

λ Insertion_sort





<head> <script src=""></script> <link rel="stylesheet" type="text/css" href="graph.css"/> <script src="graph.js"></script> <script type="text/javascript"> var graph = new Graph(20);   window.onload = function() { chart = graph.createGraph("#chart")) }   function args() { return graph.array; }   var oldI;   function update(n, x, isRunning, duration, prev) { if (duration < 0) { return; // State-less visualisation. } if (x) { graph.drawGraph(duration);   var sortedN = x.lookupInScope("sortedN"); var idx = x.lookupInScope("i"); var bars = chart.selectAll("").data(graph.array, function(d) {return d.hash;}); // Increase the sorted section when we have an index being moved down. if (typeof idx !== "undefined") { sortedN++; } bars.classed("sorted", function(d, i) {return sortedN && i<sortedN}); if (idx !== oldI) { bars.classed("index", function(d, i) {return i===idx}); oldI = idx; } } } </script> </head> <body> <div style="position:absolute;padding:2px"> <button onclick="graph.randomise(200)">Random</button> <button onclick="graph.randomise(5)">Few Unique</button> <button onclick="graph.almostSorted()">Almost sorted</button> <button onclick="graph.reverse()">Reverse</button> </div> <div id="chart"></div> </body>

algorithm/insertion_sort.1400134314.txt.gz · Last modified: 2015/02/02 08:23 (external edit)