New technologies are constantly changing. mastering some foundations is a solid foundation for learning and updating technologies in the future. Recently, I have nothing to worry about. To learn more about the previously learned data structure, I used JavaScript to implement the Sorting Algorithm in the data structure. Recently I started to learn about the data structure.
I hope to stick to it.
Because the direction is the frontend, it is implemented using JavaScript.
// Sort var testArr1 = [3, 44, 38, 5, 47, 15, 36, 26, 27, 2, 46, 4, 19, 50, 48]; var testArr2 = [3, 44, 38, 5, 47, 15, 36, 26, 27, 2, 46, 4, 19, 50, 48]; var testArr3 = [3, 44, 38, 5, 47, 15, 36, 26, 27, 2, 46, 4, 19, 50, 48]; testArr1.sort (); // sorting result: [15, 19, 2, 26, 27, 3, 36, 38, 4, 44, 46, 47, 48, 5, 50] testArr2.sort (function (a, B) {return a> B}); // sorting result: [2, 3, 4, 5, 15, 19, 26, 27, 36, 38, 44, 46, 47, 48, 50] testArr3.sort (function (a, B) {return a-B}); // sorting result: [2, 3, 4, 5, 15, 19, 26, 27, 36, 38, 44, 46, 47, 48, 50]
// Sort buckets
Var testArr1 = [3, 44, 38, 5, 47, 15, 36, 26, 27, 2, 46, 4, 19, 50, 48]; var testArr2 = [3, 44, 38, 5, 47, 15, 36, 26, 27, 2, 46, 4, 19, 50, 48]; function bubbleSort1 (array) {for (I = array. length-1; I> 0; I --) {for (j = 0; j
// Select sorting
Var testArr = [3, 44, 38, 5, 47, 15, 36, 26, 27, 2, 46, 4, 19, 50, 48]; function selectSort (array) {for (I = 0; I// Insert sorting
Var testArr = [3, 44, 38, 5, 47, 15, 36, 26, 27, 2, 46, 4, 19, 50, 48]; function insertSort (array) {for (var I = 0; I <array. length-1; I ++) {// note that I is smaller than the length of the array-1; otherwise, the array may be out of bounds, forming an endless loop var curElement = array [I + 1]; for (var j = I; j> = 0; j --) {if (curElement