Being a good software engineer not only needs to know what tools (e.g., data structures and algorithms) are available but also understand how to choose the right tools. In addition, a good software engineer also requires the knowledge of how to measure if the tool we choose does work as we expect. This article is not going to build a new tree data structure like the previous articles. Instead, we will build a tool, a Python library called Metrics, that can monitor software behavior and performance, and then we can use the tool to prove our AVL tree and red-black…
After the Red-Black Tree discussion, this article will implement another variant of the self-balancing binary search tree: the AVL Tree.
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: avl_tree.py for the AVL tree implementation and test_avl_tree.py for its unit tests. After adding these two files, our project layout becomes the following:
│ ├── __init__.py
│ ├── binary_trees
│ │ ├── __init__.py
│ │ ├── avl_tree.py
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.
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:
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.
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:
│ ├── __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.
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.
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:
commonlib, is used by many projects. The library is self-contained and has its test suite and document.
myprojhas a dependency on
[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…