(items, left, right)
| 38 | } |
| 39 | |
| 40 | function Partition(items, left, right) { |
| 41 | const x = items[right] |
| 42 | let pivotIndex = left - 1 |
| 43 | |
| 44 | for (let j = left; j < right; j++) { |
| 45 | if (items[j] <= x) { |
| 46 | pivotIndex++ |
| 47 | Swap(items, pivotIndex, j) |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | Swap(items, pivotIndex + 1, right) |
| 52 | |
| 53 | return pivotIndex + 1 |
| 54 | } |
| 55 | |
| 56 | function getRandomInt(min, max) { |
| 57 | return Math.floor(Math.random() * (max - min + 1)) + min |
no test coverage detected