{"ScriptPreparationCode":"var items = [5,3,7,6,2,9,63, 95, 63, 26, 76, 19, 65, 8, 63, 26];\r\n","TestCases":[{"Name":"t1","Code":"function swap(items, leftIndex, rightIndex){\r\n var temp = items[leftIndex];\r\n items[leftIndex] = items[rightIndex];\r\n items[rightIndex] = temp;\r\n}\r\nfunction partition(items, left, right) {\r\n var pivot = items[Math.floor((right \u002B left) / 2)], //middle element\r\n i = left, //left pointer\r\n j = right; //right pointer\r\n while (i \u003C= j) {\r\n while (items[i] \u003C pivot) {\r\n i\u002B\u002B;\r\n }\r\n while (items[j] \u003E pivot) {\r\n j--;\r\n }\r\n if (i \u003C= j) {\r\n swap(items, i, j); //sawpping two elements\r\n i\u002B\u002B;\r\n j--;\r\n }\r\n }\r\n return i;\r\n}\r\n\r\nfunction quickSort(items, left, right) {\r\n var index;\r\n if (items.length \u003E 1) {\r\n index = partition(items, left, right); //index returned from partition\r\n if (left \u003C index - 1) { //more elements on the left side of the pivot\r\n quickSort(items, left, index - 1);\r\n }\r\n if (index \u003C right) { //more elements on the right side of the pivot\r\n quickSort(items, index, right);\r\n }\r\n }\r\n return items;\r\n}\r\n\r\nconsole.log(quickSort(items, 0, items.length - 1)); \r\n\r\n","IsDeferred":false},{"Name":"t2","Code":"function quickSortBasic(array) {\r\n if(array.length \u003C 2) {\r\n return array;\r\n }\r\n\r\n var pivot = array[0];\r\n var lesserArray = [];\r\n var greaterArray = [];\r\n\r\n for (var i = 1; i \u003C array.length; i\u002B\u002B) {\r\n if ( array[i] \u003E pivot ) {\r\n greaterArray.push(array[i]);\r\n } else {\r\n lesserArray.push(array[i]);\r\n }\r\n }\r\n\r\n return quickSortBasic(lesserArray).concat(pivot, quickSortBasic(greaterArray));\r\n}\r\n\r\n\r\nconsole.log(quickSortBasic(items, 0, items.length - 1)); ","IsDeferred":false}]}