RedBlackTree

Build Status Coverage Status

Module for creating and managing red-black trees. Tree nodes have keys (a number that defines the relation between nodes) and data (anything you want).

A red-black tree is a approximately balanced binary tree that satisfies the following red-black properties:

  1. Every node is either red or black.
  2. The root is black. * We relax this rule as per to make deletion simpler in the functional realm
  3. Every leaf (NIL) is black.
  4. If a node is red, then both its children are black.
  5. For each node, all simple paths from the node to descendant leaves contain the same number of black nodes.

Using the implementantion of insert from the article "Red-black trees in a functional setting" by Chris Okasaki

Using the delete implementation from the article "FUNCTIONAL PEARL Deletion: The curse of the red-black tree" by Kimball Germane and Matthew Might

Installation

If available in Hex, the package can be installed by adding rb_tree to your list of dependencies in mix.exs:

def deps do
  [
    {:rb_tree, "~> 1.0.0"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/rb_tree.