Tree Data Structures(1)

By Administrator 19-Sep-2022

A tree structure is a hierarchical data structure which can represent multiple children under a parent node. The tree data structure has roots, branches and leaves, but it is drawn upside-down compared with the actual tree structure. We will describe the 5 types of tree structures.

Basic Characteristics of a Tree

  • A tree can have no nodes or it can have one special node known as the root and zero or more subtrees.
  • Every branch of the tree directly or indirectly derived from the root.
  • Every child has a single parent, but a single parent can have multiple children.

  • We will describe the following 6 types of tree data structures.

    (1) General Tree
    (2) Binary Tree and Complete Binary Tree
    (3) Binary Search Tree
    (4) Max Heap and Min Heap
    (5) AVL-tree
    (6) B-tree

    (1) General Tree

    A general tree is a tree data structure which follows the basic characteristics of a tree and a node can have any number of children nodes. 

    (2) Binary Tree

    A binary tree is a tree data structure that has the basic characteristics of a tree structure and some special properties, such as the fact that a node can only have two child nodes (children), known as the left child and right child.

    In a binary tree structure, a complete binary tree is one in which all final level leaves are left aligned and the level from root to all leaves is equal or different by one level at most.



    (3) Binary Search Tree

    A binary search tree is a tree data structure that based on binary tree characteristics which are at most two children nodes with additional property. This property specifies that the value (or key) of a given node's left child must be less than or equal to the parent value, while the value of the right child must be greater than or equal to the parent value.

    (4) Max-Heap and Min-Heap

    A Heap is a type of tree-based data structure in which the tree is an entire binary tree. There are two types of heaps such as max heap and min heap. 

    Max-Heap: In a Max-Heap, the key at the root node must be the greatest among all of its children. The same property must be present for all subtrees in that Binary Tree.

    Min-Heap: In a Min-Heap, the key at the root node must be the smallest of all the keys at its children. The same property must be present for all subtrees in that Binary Tree.

    (5) AVL-tree

    An AVL tree is a self-balancing binary search tree. This is the first tree introduced which automatically balances its height.

    (6) B-tree

    The B tree is a self-balancing search tree with multiple nodes that keep data sorted. Each node has two or more children and multiple keys.

    Explanation about AVL-tree and B-tree will be explained in the next post.

    Random Tips