The editor below allows you to create your own visualizations. You can use any of the builtin algorithms and data sets and/or implement your own. The editor will update the visualization with each key stroke. If this slows down your browser too much, uncheck the 'Live mode' option below the editor and use the 'Update chart' button to manually run the analysis and show its output.
class AwesomeSort extends Algorithm {constructor() {this.name = "Awesome Sort" // Ok, it's actually just Bubble Sort.this.timeComplexityBest = Complexities.linearthis.timeComplexityAverage = Complexities.quadraticthis.timeComplexityWorst = Complexities.quadratic}execute(array) {// Replace this with your own algoritm.// Don't forget to add this.incrementOpCounter() in order to count the ops!let len = array.length,swappeddo {this.incrementOpCounter()swapped = falsefor (let i = 0; i < len; i++) {this.incrementOpCounter()if (array[i] > array[i + 1]) {let tmp = array[i]array[i] = array[i + 1]array[i + 1] = tmpswapped = true}}} while (swapped)}}// Compare your custom algorithm with other algorithmsconst algorithms = [ new AwesomeSort(), Algorithms.timSort ]// Below are all the available algoritms// const algorithms = [ Algorithms.bubbleSort, Algorithms.countingSort, Algorithms.heapSort, Algorithms.insertionSort, Algorithms.mergeSort, Algorithms.quickSort, Algorithms.selectionSort, Algorithms.timSort ]// const algorithms = Algorithms.all // Shortcut for using all available algoritms (does not include your custom one!)// Use the following data setsconst dataSets = [ DataSets.random, DataSets.sorted ]// Below are the rest of the built-in data sets// const dataSets = [ DataSets.halfSorted, DataSets.sortedHalf, DataSets.semiSorted, DataSets.reversed, DataSets.same, DataSets.zigzag, DataSets.sawtooth, DataSets.square, DataSets.zeroes, DataSets.thousands, DataSets.millions ]// const dataSets = DataSets.all // Shortcut for using all available data setsrender(<ComplexityChart title="Time complexity of Awesome Sort versus Tim Sort"><ComplexitySeries/><AnalysisSeries algorithms={algorithms} dataSets={dataSets}/></ComplexityChart>)