The binary tree is the simplest tree-based data structure, and even though it’s been replaced by hash maps in many languages, it’s still useful for many applications. Variants on the binary tree exist for very useful things like database indexes, search algorithm structures, and even graphics.
I’m calling my binary tree a
BSTree for binary search tree, and the best way to describe it is that it’s another way to do a
Hashmap style key/value store. The difference is that instead of hashing the key to find a location, the
BSTree compares the key to nodes in a tree, and then walks through the tree to find the best place to store it, based on how it compares to other nodes.
Before I really explain how this works, let ...