MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / QuicksortRange

Function QuicksortRange

sort/quicksort.go:29–39  ·  view source on GitHub ↗

QuicksortRange Sorts the specified range within the array

(arr []T, low, high int)

Source from the content-addressed store, hash-verified

27
28// QuicksortRange Sorts the specified range within the array
29func QuicksortRange[T constraints.Ordered](arr []T, low, high int) {
30 if len(arr) <= 1 {
31 return
32 }
33
34 if low < high {
35 pivot := Partition(arr, low, high)
36 QuicksortRange(arr, low, pivot-1)
37 QuicksortRange(arr, pivot+1, high)
38 }
39}
40
41// Quicksort Sorts the entire array
42func Quicksort[T constraints.Ordered](arr []T) []T {

Callers 1

QuicksortFunction · 0.85

Calls 1

PartitionFunction · 0.85

Tested by

no test coverage detected