Sorting Algorithms In Brief
This article is a brief description of some set of widely used sorting techniques and it's implementations in golang . Summary: Insertion Sort Selection Sort Insertion Sort This algorithm maintains a sorted portion and unsorted portion, in the given list of elements to be sorted. It picks a corner element from unsorted portion and inserts it into correct location in the sorted portion. Here is the golang implementation of insertion sort. Run in Go Playground Here the algorithm sorts the elements in ascending order. The outer for loop, scan the array from start to end. ( with itr iterator.) The left portion pointed by outer for loop iterator will be the sorted portion. On every iteration of outer for loop, inner for loop shift the element pointed by outer iterator to its correct locations. This has been achieved by continuous comparison ( arr[inItr] ) and swapping. Selection Sort Similar to insertion sort, selection sort ...