Shun Huang

Sign in

From the Binary Search Tree: Analysis, we know the tree height is the critical factor of binary search tree’s performance. This article and the following article will implement one variant of the binary search tree that will keep the trees in balance: Red-Black Tree.

Project Setup

Follow the same style and assumption as other articles in the Build the Forest Series, the implementation assumes Python 3.9 or newer. This article adds two modules to our project: red_black_tree.py for the red-black tree implementation and test_red_black_tree.py for its unit tests. After adding these two files, our project layout becomes the following:

forest-python ├── forest…

Continue the discussion of Threaded Binary Trees; the article will implement Double Threaded Binary Search Tree, which combines the left and right single-threaded binary trees and has both advantages, but it also increases the complexity.

Project Setup

Follow the same style and assumption as other articles in the Build the Forest Series, the implementation assumes Python 3.9 or newer. This article adds two modules to our project: double_threaded_binary_trees.py for the double-threaded binary search tree implementation and test_double_threaded_binary_tree.py for its unit tests. After adding these two files, our project layout becomes the following:

forest-python ├── forest │ ├── __init__.py │ ├── binary_trees │…

The article is the third one of the Build the Forest Series. In the previous article, Binary Tree Traversal, we talked about the binary tree traversals using recursive approach and auxiliary stack. This article will build one variant of the Binary Search Tree — Threaded Binary Search Tree. Threaded binary search trees utilize empty left or right nodes’ attributes to achieve certain traversals without using a stack or recursive approach.

Project Setup

Like other articles in the Build the Forest Series, the implementation assumes Python 3.9 or newer. This article adds two modules to our project: single_threaded_binary_trees.py for the threaded binary search…


The article is the second one of the Build the Forest Series. In this article, we are not going to build a tree. Instead, we will implement the functions to traverse binary trees. When we use a data structure to manage data, one important use case is to go over all the data we manage. That’s why tree traversal is essential.

Traversal is a method of examining the nodes of a tree systematically to visit each node exactly once. There are many ways to traverse a binary tree: in-order, pre-order, post-order, and level-order. The names come from the relative position…


Building software projects is hard, and it also requires broad knowledge such as writing code, understanding algorithms, set up environments, testing, and deployment. Besides, each language has its ways of implementing things, even if all the languages were object-oriented programming languages. Getting into the habit of thinking about software development from various angles takes time. This project, Build the Forest Series, tries to provide a different perspective to learn software development and tree data structures by building a few tree data structures (the forest) in Python way with object-oriented programming.

Why Trees?

Trees are essential data structures that solve many…


Visual Studio Code (VS Code) has been my favorite editor for years. With the numerous extensions and community support, VS Code has become one of the most popular editors for programming. Windows Subsystem for Linux (WSL) lets developers run a Linux environment directly on Windows. The powerful combination of these two provides programmers a great way to write software.

VS Code has excellent language support, including Scala. Most Scala developers use IntelliJ as their development tool. Therefore, not many tutorials exist for using VS Code as a Scala development tool. This article is a brief tutorial of the VS Code…


[Updated: December 27, 2020]

As a software engineer, it is not uncommon that we work on a project that has a dependency on the other project that we also work on at the same time. The scenario may look like the following:

We have two projects, and each of them has its Git repository:

  • A common library, say commonlib, is used by many projects. The library is self-contained and has its test suite and document.
  • A project called myprojhas a dependency on commonlib.

While we are working on myproj, we may also need to update commonlibat the same time. If…


[Updated: January 14, 2021]

As a developer, we all know the importance of code documenting: Good code is not only self-explanatory but also well-documented. However, we also struggle with keeping documents up to date, especially if we maintain the source code and its documents separately. If we can generate the document based on the source code or based on the code comments, we have a better chance to keep the document up to date.

Sphinx is a tool to build documents from the code. It supports many programming languages, and it is widely used in Python projects, including the official…


[Updated: January 3, 2021]

Visual Studio Code (VS Code) has been my favorite editor for a few years. With the activity enhancement made by Microsoft and the community, VS Code has numerous extensions to satisfy different development needs. With the remote development extension, I can now use the VS Code for my daily work and open source projects in all environments. This article is a brief tutorial of the VS Code setup for Python developments — the setup I use daily. Hopefully, this tutorial could help people who want to use the VS Code for Python development. Besides, VS Code…

Shun Huang

A software and data engineer. I like to share the knowledge I learned. I believe knowledge belongs to all humanity. My Website: https://shunsvineyard.info

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