Algae v0.12.2 Algae.Tree.Binary View Source

Represent a binary tree. Nodes may be empty, a leaf, or a branch (recursive subtree).

Examples

iex> alias Algae.Tree.Binary, as: BTree
...>
...> BTree.Branch.new(
...>   42,
...>   BTree.Branch.new(77),
...>   BTree.Branch.new(
...>     1234,
...>     BTree.Branch.new(98),
...>     BTree.Branch.new(32)
...>   )
...> )
%Algae.Tree.Binary.Branch{
  value: 42,
  left: %Algae.Tree.Binary.Branch{
    value: 77,
    left:  %Algae.Tree.Binary.Empty{},
    right: %Algae.Tree.Binary.Empty{}
  },
  right: %Algae.Tree.Binary.Branch{
    value: 1234,
    left:  %Algae.Tree.Binary.Branch{
      value: 98,
      left:  %Algae.Tree.Binary.Empty{},
      right: %Algae.Tree.Binary.Empty{}
    },
    right: %Algae.Tree.Binary.Branch{
      value: 32,
      left:  %Algae.Tree.Binary.Empty{},
      right: %Algae.Tree.Binary.Empty{}
    }
  }
}

Link to this section Summary

Link to this section Types

Link to this section Functions