There are many strategies for balancing search trees to ensure logarithmic running time for their operations. All the approaches involve modifying them when you insert or delete elements and rebalancing them to minimize their height, and in this chapter, I will show you one technique: the
red-black search trees. It is a search tree where we add one of two
colors
to each node, either
red or
black:
class Node(object):
def __init__(self, value,
colour = RED,
left ...