Tree

08 Feb 2022 . data structure .

Full Binary Tree

The layers of the binary tree is k, and the total number of nodes is (2^k) -1.

Completed Binary Tree

Except for the last layer, the rest of the layers are full and the last layer is either full or missing several consecutive nodes on the right.


Balanced Binary Tree

  • It can be an empty tree.
  • If it is not an empty tree, the absolute height difference between its left and right subtrees does not exceed 1, and the left and right subtrees are a balanced binary tree.

Applications

  • It’s widely used in computer networks for storing routing table information.
  • Decision Trees.

B-Tree

The B Tree is a type of m-way tree that is commonly used for disc access. A B-Tree with order m can have at most m children and every node have m/2 ~ m-1 keys.

Red Black Tree

  1. Each node is red or black.
  2. The root node is always black.
  3. Each leaf node is a black empty node (NIL node).
  4. If the node is red, its child node must be black (reversely not necessarily).
  5. Each path from the root node to the leaf node or empty child node must contain the same number of black nodes (the same black height).