be considered to have been sorted | instancecsのブログ

instancecsのブログ

ブログの説明を入力します。

Written interview often involves a variety of Nike Air Max algorithms, this article briefly describes some of the commonly used algorithms and implemented in JavaScript. 1, insertion sort 1) Introduction insertion sort algorithm (Insertion-Sort) algorithm description is a simple and intuitive sorting algorithms. It Air Jordan Outlet works by building an ordered sequence, for unsorted data, sorted sequence scanning forward from the rear, locate the position and insert. Insertion sort in Air Max 2012 White Black Grey the realization, usually sorted in-place (that just sort used O (1) extra space), thus scanning forward from BHM Jordan CP3.VI Black History Month Chris Paul PE Sale the process, the need to repeatedly move back gradually sorted element bit , the latest element provides insertion space. 2) algorithmic descriptions and achieve general, insertion sort are used in-place implemented on the array. The algorithm is described as follows: starting from the first element, the element can be considered to have been sorted; takes the next element in the sequence of elements from the already sorted after scanning forward; if the element (sorted) is greater than the new elements, The element moves to the next position; Repeat step 3 until you find an element sorted less than or equal to the new position of the element; a new element into the position after; Repeat steps 2 to 5. JavaScript code: function insertionSort (array) {if (Object.prototype.toString.call (array) .slice (8, -1) === Nike 6.0 Mavrk Mid 2 Skate Shoes Red Black 'Array') {for (var i = 1; i \u0026 lt; array. length; i ++) {var key = array [i]; var j = i - 1; while (j \u0026 gt; = 0 \u0026 amp; \u0026 amp; array [j] \u0026 gt; key) {array [j Jordan CP3 VI + 1] = array [j ]; j--;} array [j + 1] = key;} return array;} else {return 'array is not an Array!';}} 3) analysis of algorithms best case: the input array in ascending order. T (n) = O (n) worst-case scenario: the input array are arranged in descending order. T (n) = Black Grey Blue Nike Air LeBron E.E. 2013 Online O (n2) Average case: T (n) = O (n2) Second, bipartite insertion sort 1) algorithm Introduction dichotomous insert (Binary-insert-sort) to sort an on direct insertion sort algorithm Small changes to the sorting algorithms. With direct insertion sort algorithm to find the biggest difference is that when the insertion position using a binary search approach, there is a certain increase in speed. 2) algorithmic descriptions and achieve general, insertion sort are used in-place implemented on the array. The algorithm is described as follows: starting from the first element, the element can be considered to have been sorted; takes the next element in the sequence of elements New New Nike Tr Fit Shoes Silver Orange Womens Nike Free 3 V3 Trainers Black Grey already sorted in binary search to the first number is larger than its location; the new element into after the position; repeat the above steps. JavaScript code: function binaryInsertionSort (array) {if (Object.prototype.toString.call (array) .slice (8, -1) === Nike Dunk Heels 'Array') {for (var i = 1; i \u0026 lt; array. length; i ++) {var key = array [i], left = 0, right = i - 1; while (left \u0026 lt; = right) {var middle = parseInt ((left + right) / 2); if (key \u0026 lt ; array [middle]) {right = middle - 1;} else {left = middle + 1;}} for (var j = i - 1; j \u0026 gt; = left; j--) {array [j + 1] = array [j];} array [left] = key;} return array;} else {return 'array is not an Array!';}} 3) analysis of algorithms best case: New Womens Nike Free 3 V3 Trainers Black Grey T (n) = O (nlogn) Worst case: T (n) = O (n2) Average case: T (n) = O (n2) Third, choose Sort 1) Introduction Selection Sort Algorithm (Selection-sort) is a simple and intuitive sorting algorithms. It works: First, find the minimum unsorted sequence (large) elements, stored in the collating sequence of the starting Nike 6.0 Mavrk Mid 2 Mens Skate Shoes Black position, and then again from the remaining unsorted elements continue to look for the smallest (large) element, and then Air Max 2012 Womens Navy Blue White into the sorted sequence The end. And so on, until all elements are sorted. 2) algorithmic descriptions and implement n Sort records directly through n-1 times can directly select the sort to get the results in order. The algorithm is described as Air Jordan Heel follows: Initial state: disordered region is R [1..n], ordered region is empty; 2015 Nike Free 5.0 i-times sorted (i = 1,2,3 ... n-1) at the beginning of the current ordered region and disorderly area were R [1..i-1] and R (i..n). The trip sort keywords selected records from the current minimum of disorderly area