Dictionary Using Red Black Trees

A Visual Journey and Ultimate Guide to Dictionary Using Red Black Trees

The read-only operations, such as search or tree traversal, on a redblack tree require no modification from those used for binary search trees, because every redblack tree is a special case of a simple binary search tree.

In the Red-Black Tree, each node is either red or black, the root of the tree is always black, and all leaves (NIL nodes) are black. If the red node has children then the children are always black which means no two red nodes are adjacent.

Illustration of Dictionary Using Red Black Trees
Dictionary Using Red Black Trees

I'm trying to implement a Dictionary using a Red-Black tree. I've tested the insert method and it seems to work good, the RBtree seems to keep the correct shape and colors.

Dictionary Using Red Black Trees photo
Dictionary Using Red Black Trees

And after a bit of thinking and experimenting, I've found that dictionary implementation based on hash tables won't work, and that I need a different data structure. This post will explain why, and also why I settled on red-black trees instead. Let's begin with data serialization.

A closer look at Dictionary Using Red Black Trees
Dictionary Using Red Black Trees

Red-Black tree is a self-balancing binary search tree in which each node contains an extra bit for denoting the color of the node, either red or black. In this tutorial, you will understand the working of various operations of a red-black tree with working code in C, C++, Java, and Python.

Visual Collection