March 2019
Intermediate to advanced
336 pages
9h 9m
English
The main method initializes the elements array. The elements are printed before and after sorting in the following code snippet:
//main methodfunc main() { var elements []int elements = []int{11, 4, 18, 6, 19, 21, 71, 13, 15, 2} fmt.Println("Before Sorting ", elements) SelectionSorter(elements) fmt.Println("After Sorting", elements)}
Run the following command to execute the selection_sort.go file:
go run selection_sort.go
The output is as follows:

Let's take a look at the insertion sort algorithm in the following section.
Read now
Unlock full access