March 2019
Intermediate to advanced
336 pages
9h 9m
English
The main method asks the user to input the number of elements and the elements to be read. The array is initialized and printed before and after sorting, as follows:
// main methodfunc main() { var num int fmt.Print("Enter Number of Elements: ") fmt.Scan(&num) var array = make([]int, num) var i int for i = 0; i < num; i++ { fmt.Print("array[", i, "]: ") fmt.Scan(&array[i]) } fmt.Print("Elements: ", array, "\n") QuickSorter(array, 0, num-1) fmt.Print("Sorted Elements: ", array, "\n")}
Run the following command to execute the quick_sort.go file:
go run quick_sort.go
The output is as follows:

Now that we are done with sort algorithms, ...
Read now
Unlock full access