Recent Articles

Let's Learn Algorithms - Updated Format, MOAR VIDEOS!

Join the discussion on Reddit I started the Let's Learn Algorithms series originally by writing tutorials that would: Teach how an algorithm works Demonstrate how to implement that algorithm in code Provide some practice problems so you can get real practice implementing the algorithm in different scenarios (2) and (3) are in my opinion incredibly important pieces to the puzzle that are often missing in many other courses, so I really try to give them just as much focus as the initial lesson that just teaches how the algorithm works.

Representing a Binary Tree in Go Code

See https://play.golang.org/p/u4E6mrios0 for the completed code from this video. In this video we learn how to represent a binary tree in Go code. Once we have the basic structure in place, we then go a step further and define an input file format that we can use to read in arbitrary binary trees moving forward to test our algorithms with. This post is part of the Let's Learn Algorithms series where we learn how algorithms work, see how to implement them, and then spend some time working on practice problems to reinforce how the implementation details work, as well as to help you learn to recognize problems that could be solved using any particular algorithm.

Depth First Search (DFS) on a Binary Tree

In this video we cover how the depth first search algorithm works. We do so by starting with a binary tree and walking through how the algorithm would iterate over the tree searching for a specific node. We intentionally start with a tree because this removes a lot of complicating factors that might be present in other graphs, such as running into a cycle, but everything you learn here will be applicable to when we start working with cyclical graphs to also run our DFS.

Trees are also Graphs

In this video we discuss a specific type of graph - the binary tree. In the video we discuss some of the properties of a tree that make is a special type of graph, and then we discuss a few common properties of trees that aren’t always present, but are often there in order to make trees a more optimal data structure to work with. This is all used to set the stage for upcoming videos where we start to implement some algorithms first using trees, and then later on more general graphs.

What is a Graph?

In this video we cover all of the basics about graphs. We start be defining the different parts of a graph, and then jump into a real world example where we translate a map with cities and highways into a graph. Finally, we discuss some of the common attributes you might find on a graph, such as cost, capacity, directional edges, and even cycles, and relate these all to our graph derived from a map of cities and highways.

Beginners - stop limiting your projects to things that are "useful"

I posted this recently on Reddit, but I felt it was important enough to post again here. One of the most common themes I see with beginners or people learning a new language is the question “What should I build?” The problem isn’t the question itself, but that so many people want to build something that is both: Useful to everyone (eg may be a popular open source project), and Simple enough that they could build it as their 1st, 2nd, or even 5th project.

Popular Articles

6 Tips for Using Strings in Go

Learn how to perform common operations with strings in Go. This article discusses how to write multiline strings, concatenate strings efficiently, convert various data types into strings, checking for prefixes, and converting strings to byte slices.

Using Functions Inside Go Templates

Go's template package provides many useful built-in functions. Learn to use a few of the more common ones, as well as how to add custom fucntions to your templates so that you can add any functionality you need.

Connecting to a PostgreSQL database with Go's database/sql package

This tutorial explains how to connect to a Postgres DB using the database/sql and lib/pq packages. It also covers potential errors and solutions.

Creating Random Strings in Go

A tutorial explaining how to create a custom rand package with functions for creating random strings of varying length with custom of preset character sets.

Inserting records into a PostgreSQL database with Go's database/sql package

Learn to insert new records into a Postgres database using Go's database/sql package, along with how to get the resulting ID of newly created records.

How to use slice capacity and length in Go

Learn about the difference between capacity and length and how to properly utilize them to make your Go code faster, cleaner, and memory efficient.

My Latest Progress Update

Writing Course Notes

In this progress update we explore why it takes me so long to complete a project when using it to come up with course notes. I'll also give you an inside look at my notes that I use for courses.

View past progress updates

↓ Or check out some of my longer series. ↓

Each series covers a broader topic and is composed of several articles

Using PostgreSQL with Go

PostgreSQL is an open source relational database system that has been around for well over a decade and has proven to be a great all around storage choice when developing a web application.

In this series we are going to walk through everything from first installing PostgreSQL 9.5 all the way to using it with a Go application. While this post will cover all of the basics required to get started using SQL with Golang, it is not a full course on SQL. It is instead intended to guide you by giving you enough information to be productive, while not overloading you with details that can be learned as you progress.

In this series we will cover topics like:

  • Installing PostgreSQL on various operating systems (Ubuntu Linux, Mac OS, etc)
  • Interacting with a PostgreSQL database using raw SQL. This includes querying, inserting, updating, and deleting records.
  • Interacting with a PostgreSQL database using the database/sql package provided by Go's standard library. Again, this includes querying, inserting, updating, and deleting records.
  • Using ORMs and other third party librarys to interact with SQL databases
Let's Learn Algorithms

This series is no longer being updated. Instead, check out the course I created based on it - Algorithms with Go

Algorithms are a core component in a computer science education, and when taught properly they can help a developer improve his or her skills massively. In this series we will work to both understand how common computer algorithms work, as well as how to properly code each of them in Go.

By coding each algorithm as we learn it, you will develop the skills necessary to translate a conceptual idea into correct and efficient code. While many developers will know how to solve a problem set before them, oftentimes bugs and issues can stem from minor mistakes that algorithm practice can help remedy.

In addition to coding each algorithm we will also discuss how it works as well as the efficiency of each algorithm. That is, we will discuss how fast or slow the code will be based on the size of the input. This is important because in many real world situations you can opt for simpler - but slower - code if you know your inputs won't be too large. Alternatively, you could determine that the simpler solution won't work for your inputs and know that you will need to spend some extra time on a more efficient algorithm.

If you are relatively new to programmer, or simply don't have a formal computer science education, I invite you to check out these articles. You won't be disappointed!

Avatar of Jon Calhoun
Articles and Tutorials by
Jon Calhoun

Jon Calhoun is a full stack web developer who teaches about Go, web development, algorithms, and anything programming. If you haven't already, you should totally check out his Go courses.

Previously, Jon worked at several statups including co-founding EasyPost, a shipping API used by several fortune 500 companies. Prior to that Jon worked at Google, competed at world finals in programming competitions, and has been programming since he was a child.

Recent Articles All Articles Mini-Series Progress Updates Tags About Me Go Courses

©2018 Jonathan Calhoun. All rights reserved.