March 2019
Intermediate to advanced
336 pages
9h 9m
English
The main method initializes the sequence by invoking the randomSequence function, as shown in the following code. The InsertionSorter function takes the sequence and sorts it in ascending order:
//main methodfunc main() { var sequence []int sequence = randomSequence(24) fmt.Println("\n^^^^^^ Before Sorting ^^^ \n\n", sequence) InsertionSorter(sequence) fmt.Println("\n--- After Sorting ---\n\n", sequence, "\n")}
Run the following command to execute the insertion_sort.go file:
go run insertion_sort.go
The output is as follows:

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