Exercise 40. Binary Search Trees
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 ...
Get Learn C the Hard Way: A Clear & Direct Introduction To Modern C Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.