3. What will be the output of the following Go code snippet after calling
quickSort(arr, 0, len(arr)-1)?
func partition(arr []int, low, high int) int {
pivot := arr[high]
i := low - 1
for j := low; j < high; j++ {
if arr[j] < pivot {
i++
arr[i], arr[j] = arr[j], arr[i]
}
}
arr[i+1], arr[high] = arr[high], arr[i+1]
return i + 1
}
func quickSort(arr []int, low, high int) {
if low < high {
pi := partition(arr, low, high)
quickSort(arr, low, pi-1)
quickSort(arr, pi+1, high)
}
}
func main() {
arr := []int{4, 2, 7, 1}
quickSort(arr, 0, len(arr)-1)
fmt.Println(arr)
}