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: 1234567891011121314151617function bubbleSort(a) { for (..
更多Sort 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: 123456789101112131415161718192021var { less } = require("./Shuffle&quo..
更多