Skip to content

Tree

A tree is a hierarchical data structure close to a graph, with some constraints:

  • It has a root node
  • Each node has only one parent (except for the root node)
  • It's acyclic (no loops)

Types

Binary tree

In a binary tree, each item within the tree has at most two children.

Example of a tree data structure

Tree rotation

A tree rotation changes the structure of the tree without interfering with the order of the elements.

Spanning tree

A graph can contains a spanning tree, which connect all its vertices together, without create loops.

Minimum Spanning Tree

A Minimum Spanning Tree (MST) is a spanning tree which connect vertices together by edges with minimum total weight.

Example of a Minimum Spanning Tree