MCPcopy Create free account
hub / github.com/careercup/CtCI-6th-Edition-JavaScript / swap

Function swap

chapter10/sortingAlgos/quickSort.js:3–8  ·  view source on GitHub ↗
(array, left, right)

Source from the content-addressed store, hash-verified

1// write the quickSort algorithm
2
3const swap = (array, left, right) => {
4 const temp1 = array[left];
5 const temp2 = array[right];
6 array[left] = temp2;
7 array[right] = temp1;
8};
9
10const partition = (array, left, right) => {
11 const pivotIndex = Math.floor((left + right) / 2);

Callers 1

partitionFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected