image credits: https://unsplash.com/photos/fRGoTJFQAHM

COVID-19 took the world by surprise, causing one of the most devastating financial crises of all time. Many people lost their jobs, and many companies went out of business trying to adapt to the new reality.

However, it is not all bad news. One of the positive aspects of this terrible pandemic is that many companies realized that office space is not required to do amazing work. That realization helped them reduce operational costs and start fishing for talent on a bigger pond — namely, the entire world.

While many people are still struggling to adapt to the new reality…


One of the road-blocking stones I found when I start learning functional programming languages, was the lack of loop constructs in their syntax. Back then, I was curious about how functional programmers get even the most straightforward programs to work without using loops. I mean, you need some form of a loop to print numbers for 1 to 10, right?

Wrong!

Soon, I realized that the lack of loops didn’t mean that you can’t iterate over sequences of elements; it means that you have to use alternative techniques like recursive algorithms.

In this post, I’ll show you how to create…


Today I’ll share some thoughts about recurring questions I got at Codementor, such as:

“How can I get all possible combinations for a given dice roll?”

“How many combinations add up to 7 in a pair of dice?”

“Is it possible to use a recursive algorithm to count all dice combinations?”

To answer these questions (and variants of them that involve coins, card decks, and whatnot) we can use combinatorics, a branch of mathematics that deals with combinations of objects belonging to a finite set of elements.

While I’m not an expert in the subject, in this post I’ll try…


As we start moving away from trivial programs, we need a way to split our code into multiple files. Of course, Go does support this feature, but not in the same way as .NET does.

In this post, we are going to take a look at how to create a Go “project” that allows us to distribute functions into multiple files.

Let’s start by doing a quick review of how we usually do it in .NET. Assuming you use Visual Studio, the typical path to create a console app is from the file menu:

File -> New Project -> Console…


I’m going to take a hiatus from algorithms and data structures in Ruby to write about my experiences while learning Go after more than a decade of .NET.

If you are an experienced .NET developer who happens to need to learn Go in no-time, this guide might help you.

By focusing on the shortlist of stuff that you don’t know about Go and leaving the rest to your “muscle memory,” this guide might be able to halve the time that it takes to learn Go from scratch.

Let’s start with a quick example to see what I mean.

On C-Style…


Writing this series has been a lot of fun, and based on feedback, I decided to write this post to provide an index (so posts can be bookmarked), and to tell you what this series was all about and what you can learn from it. So, with no further ado, let’s dive in.

The series starts with essential data structures like linked lists and stacks, then moves to advanced data structures like binary search trees and graphs, and finally, it introduces the concept of persistent data structures like the ones you find in functional programming languages like Clojure or Haskell.


To close up this series, I want to introduce the concept of persistent data structures, a term coined by Driscoll et al. in an article from 1986 that these days it’s at the core of most purely functional data structures.

The first time I heard the term was in a talk by Rich Hickey, the creator of Clojure, where he showed how Closure’s data structures internally deal with mutations (or the lack of them, actually).

On this post, we are going to implement a “persistent” linked list, which is a data structure that behaves almost the same as the singly…


A graph is a data structure that allows us to represent data in terms of objects and relationships. Objects on a graph are called vertices (or nodes), and their connections to other nodes are called edges.

    A <-- (this is vertex/node.)
/ \
B - C
\ / <- (this is an edge.)
D

A graph is said to be undirected where relationships between objects are bidirectional (like the one in the section above) or directed otherwise.

Directed graphs can be cyclic when a node points back to the node that references it, or acyclic when there are no back-pointers…


Binary search trees, or BTSs for short, are data structures designed to perform fast lookups on large datasets. The subject of this post is AVL trees, a special kind of self-balancing BST named after its creators Adelson-Velskii and Landis where the height difference between the left and right subtrees (the balance factor) is always in the range (-1..1) giving us O(log2 n) lookups.

On AVL trees nodes arranged in descendant order, and they can’t contain duplicate keys. These properties are important because most of its methods rely on them.

Let’s start by looking at how lookups work.

How lookups work

On this data…


A tree is a data structure that allows us to represent different forms of hierarchical data. The DOM in HTML pages, files, and folders in our disc, and the internal representation of Ruby programs are all different forms of data that can be represented using trees. On this post, we are going to focus on binary trees.

The way we usually classify trees is by their branching factor, a number that describes how nodes multiply as we add more levels to the tree.

Unsurprisingly, the branching factor of binary trees is two.

This is how a binary tree looks like:

Ale Miralles

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store