Tell us what’s happening:
I’ve already failed with implementing recursive in No repeats please which i couldn’t do myself. This task looks a little bit clearer though I can’t understand where to put recursive and more precisely do i need to add arguments (array, start, end) to quickSort function?
In next code i did only partitioning round and found index of pivot from which i can divide into subarrays.
Your code so far
function quickSort(array) {
// change code below this line
let pivot = array[0];
for(let i = 1; i < array.length;i++){//
if(array[i] < pivot){
let a = parseInt(array.splice(i,1));
array.unshift(a);
}
}
let ind = array.indexOf(pivot);
// change code above this line
return array;
}
console.log(quickSort([100, 4, 2, 8, 345, 123, 43, 32, 5643, 63, 123, 43, 2, 55, 1, 234, 92]));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36
.
Challenge: Implement Quick Sort
Link to the challenge:
https://www.freecodecamp.org/learn/coding-interview-prep/algorithms/implement-quick-sort