(arr []T, low, high int)
| 13 | import "github.com/TheAlgorithms/Go/constraints" |
| 14 | |
| 15 | func Partition[T constraints.Ordered](arr []T, low, high int) int { |
| 16 | index := low - 1 |
| 17 | pivotElement := arr[high] |
| 18 | for i := low; i < high; i++ { |
| 19 | if arr[i] <= pivotElement { |
| 20 | index += 1 |
| 21 | arr[index], arr[i] = arr[i], arr[index] |
| 22 | } |
| 23 | } |
| 24 | arr[index+1], arr[high] = arr[high], arr[index+1] |
| 25 | return index + 1 |
| 26 | } |
| 27 | |
| 28 | // QuicksortRange Sorts the specified range within the array |
| 29 | func QuicksortRange[T constraints.Ordered](arr []T, low, high int) { |
no outgoing calls
no test coverage detected