Mar 19, 2022
Introduction # Another way of sorting an array is by using the insertion sort method. In this case we start at position 1 in the array1. We then set j = i, or in this case, 1. We then compare array[j - 1] with array[j], i.e. array[0] and array[1]. If array[0] is greater than array[1], we swap them. Then we subtract 1 from j and if j is greater than zero, we do the next j, other we break and do the next i.
...
Mar 19, 2022
Introduction # There are many different ways of sorting an array. One the simplest ways is the bubble sort. Essentially you start at the beginning of the array and compare element i with element i + 1. If i > i + 1, swap them, and increment i. This way the larger value bubbles up the array, hence the name bubble sort. You repeat this until there you can run through the entire array without swapping anything.
...
Mar 19, 2022
Introduction # The Fibonacci sequence is probably one of the best know number sequences, with each number in the sequence being the sum of the two numbers that precede it, with 0 and 1 normally being the first two numbers of the sequence. The mathematical equation describing it is Xn+2= Xn+1 + Xn.
Solution Using a For Loop # We can use the basic structure of the fizzbizz program as a template for writing this program.
...
Mar 19, 2022
Introduction # Go is a language I have only recently learnt, and so I decided, for practice, to write some of the standard algorithms and data structures in Go. None of these are particular new, all of them can be found on the web already, but the exercise for me was partly to remind myself of them, and partly to see what I learned along the way. The first one I decided to start off with was FizzBuzz.
...