|
|
|
@ -9,7 +9,6 @@ package main
|
|
|
|
|
|
|
|
|
|
import "fmt"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func Swap(a *int, b *int) {
|
|
|
|
|
t := *a
|
|
|
|
|
*a = *b
|
|
|
|
@ -25,7 +24,7 @@ func Partition(arr []int, start, end int) int {
|
|
|
|
|
|
|
|
|
|
for j := start; j <= end-1; j++ {
|
|
|
|
|
//If current element is smaller than or equal to pivot
|
|
|
|
|
if(arr[j] <= pivot){
|
|
|
|
|
if arr[j] <= pivot {
|
|
|
|
|
i++
|
|
|
|
|
Swap(&arr[i], &arr[j])
|
|
|
|
|
}
|
|
|
|
@ -42,7 +41,7 @@ func Partition(arr []int, start, end int) int {
|
|
|
|
|
end -> Ending index
|
|
|
|
|
*/
|
|
|
|
|
func QuickSort(arr []int, start, end int) {
|
|
|
|
|
if(start < end){
|
|
|
|
|
if start < end {
|
|
|
|
|
//pi is partitioning index, arr[p] is now at right place
|
|
|
|
|
var pi int = Partition(arr, start, end)
|
|
|
|
|
|
|
|
|
|