Below you will find pages that utilize the taxonomy term “algorithms”

Posts

# Insertion Sort in Go (Golang) with test

What is Insertion Sort? Insertion sort is one of the simplest sorting algorithm. It breaks the input into sorted and unsorted list, picks next element from unsorted list and puts it into right place in sorted list.
Let’s break this down into concrete steps -
iterate over the array n - 1 times that is from index 1 to n-1 in each iteration let’s say i, pick i+1th element and put it into existing sorted list [0, i] such that the resultant list [0, i+1] is also sorted Implementation Let’s create a new directory inside $GOPATH/src.

Posts

# Bubble Sort in Go (Golang) with test

What is Bubble Sort? Quoting from wiki -
Bubble sort, sometimes referred to as sinking sort, is a simple sorting algorithm that repeatedly steps through the list, compares adjacent pairs and swaps them if they are in the wrong order. The pass through the list is repeated until the list is sorted.
So the idea is to bubble up the smallest value in each iteration. Let’s break this down into concrete steps -