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 moreSort Algorithm(2): Elementary Sort Javascript Implement - Shell Sort
Shell Sort is a very efficient sorting algorithm; its time complexity can almost reach O(n) in real-world production. The code Shell Sort moves elements in the same way as Selection Sort, but it seeks local sorting and then achieves global sorting. Let’s see How it works: var { less } = require("./Shuffle"); function shellSort(a) {..
Read more