Here you can find the source of swap(index1, index2)
Array.prototype.swap = function(index1, index2) { let temp = this[index1]; // ww w.j av a2s . co m this[index1] = this[index2]; this[index2] = temp };
'use strict'; Array.prototype.swap = function (i, j) { const temp = this[i]; this[i] = this[j]; this[j] = temp; function qsort (arr, lo=0, hi=arr.length - 1) { if (lo >= hi) return; arr.swap(lo, Math.floor(Math.random() * (hi - lo)) + lo); ...
Array.prototype.swap = function (i, j) { var tmp = this[i]; this[i] = this[j]; this[j] = tmp; };
Array.prototype.swap = function(i,j){ var a = this; if(i!=j){ a[j]^=a[i]; a[i]^=a[j]; a[j]^=a[i];
function quickSort(arr){ function partition(low, high){ if(high - low < 2){ return var pivot = arr[low] var wall = low for(var i = low; i <= high; i++){ if(arr[i] < pivot){ ...
Array.prototype.swap = function(index1, index2) { var temp = this[index1]; this[index1] = this[index2]; this[index2] = temp; };
export default function stringPermutation(string) { let permutations = [] function recursivePermutations(array, index) { if(index === array.length) { permutations.push(array.join('')) return for (let i = index; i < array.length; i++) { let copy = array.slice(0) ...
Array.prototype.swap = function(index_A, index_B) { var input = this; var temp = input[index_A]; input[index_A] = input[index_B]; input[index_B] = temp;
Array.prototype.swap = function (one, two) { var tmp = this[one]; this[one] = this[two]; this[two] = tmp; function randInt (low, high) { return Math.floor(Math.random() * (high - low + 1)) + low; function randChar () { ...
Array.prototype.swap = function(pos1, pos2) { var temp = this[pos1]; this[pos1] = this[pos2]; this[pos2] = temp;