This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function insertionSort(arr) { | |
| for (var i = 1; i < arr.length; i++) { | |
| if (arr[i] < arr[i-1]) { | |
| for (var j = 0; j <= i; j++) { | |
| if (arr[j] > arr[i]) { | |
| var temp = arr[j]; | |
| arr[j] = arr[i] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function insertionSort(arr){ | |
| var currentVal; | |
| for(var i = 1; i < arr.length; i++){ | |
| currentVal = arr[i]; | |
| for(var j = i - 1; j >= 0 && arr[j] > currentVal; j--) { | |
| arr[j+1] = arr[j] | |
| } | |
| arr[j+1] = currentVal; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function merge(arr1, arr2) { | |
| let i = 0; | |
| let j = 0; | |
| let merged = []; | |
| let arr1Full = false; | |
| let arr2Full = false; | |
| while (arr1Full === false && arr2Full === false) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function almostIncreasingSequence(sequence) { | |
| var i = 0; | |
| var spliced; | |
| function checkValid(arr) { | |
| if (i > sequence.length) { | |
| return false | |
| } |
OlderNewer