Leo Liu's blog

Tags · Algorithm

Home

About

Archives

JavascriptAlgorithmSort

Sort Algorithm(1): Elementary Sort Javascript Implement - Selection, Insertion, Bubble Sort

Elementary Sort, The slowest and simplest Sort algorithm, time complexity is O(n^2) Bubble SortAs Its name, the bigger element will be like a heavy item, Sinking to the bottom of the water, and the small one will swim up to the surface Here’s the algorithm animation: Bubble Sort javascript code: function bubbleSort(a) { for (let i = a.length - 1; i ..

Read more