golang

Today I learned How to Read Stdout in Go Tests

Being able to read the output of a function can be useful to read some good your tests are failing. Here’s how I did it. The problem# I am currently in the middle of building my lightweight configuration loader called Pluma. I was writing tests for one of the exported helper functions FromEnv which is supposed to read configurations from the environment variables and load them into a map. All the test cases were passing except the ones where the user passes a prefix for the variables.
Read more >

Algorithms

SEARCH ALGORITHMS# Linear Search# Linear search goes over all elements and checks if it is the target element. Since the search has to go through all elements in the worst case where there the values is not there, it has a complexity of $O(n)$. // golang package search func Linear(items []int, target int) bool { for _, n := range items { if n == target { return true } } return false } Binary Search# Binary search is used to find items in an ordered list by iteratively halving the input.
Read more >

Data Structures

A data structure is a way of representing data in a program, and storing it in memory. There are many structures with their pros and cons, and uses cases. In these notes, we are going to go through some of them and look at how they function and when to use them. Static Array# Arrays are a contiguous (non-breaking) space in memory with an index for each byte of memory.
Read more >

Big-O Complexity Notation

Big O complexity notation is used to give a general idea of the performance of an algorithm in terms of resources such as time or memory as the input grows larger. It is not a measure of true performance and is only a guide. The differences between the various algorithms are only seen on really large inputs. The notation uses the syntax $O(v)$ where $v$ is an expression of complexity. d
Read more >