# Introduction to Tree Data Structure

By | July 14, 2020

What is a tree?

A Tree is a data structure similar to a linked list but instead of each node pointing simply to the next node in a linear fashion. Each Node points a number of nodes. A tree is an example of a non-linear data structure. The Tree Data structure is a way of representing the hierarchical nature of the structure of a graphical form.

In trees ADT (Abstract data type) the order of the is not important. if we need ordering information then linear data structures like a linked list, stacks, queues, etc. can be used.

Some Key Points About Tree Data Structure:

•  The root of a tree is the node with no parents. There can be at most one root node in a tree (Node A in the above diagram)
• In a tree, an edge is represented by the link from parent to child
•  A node with no children is called a leaf node
•  Children of the same parent are usually called siblings (B, C, D are siblings of A and E, F are the siblings of B)
•  A node p is an ancestor of node q if there exists a path from the root to q and P appears on the path. The mode q is called a descendant of p. for example, A, C, and G  are the ancestors of K
• The set of all nodes at a given depth is called the level of the tree (B, C, and D Are the same level).  The root node is level zero.
• The depth of a node is the length of the path from the root to the node (Depth of G is 2, A-C-G)
• The height of a node in the length of the path from that node to the deepest node. The height of a tree is the length of a path from the root to the deepest node in the tree. If the tree has only one node then a tree has a height of ZERO.
• If every node in a tree has only one child (except leaf nodes) then we call such trees skew trees.  If every node has an only left child then we call them left skew trees.  Similarly, if every node in a tree has an only right child then we call them right skew trees

You May Also Like:

That’s all about Introduction to Tree Data Structure
If you have any feedback or suggestion please feel free to drop in below comment box.