Code Pumpkin

Tree Data Structure Terminologies – Set 1

July 1, 2018
Posted by Pumpkin

In this article, we will discuss one of the important non-linear data structure in computer science, Tree. Many real-life problems can be represented and solved using Tree data structure. 

In this article, we will understand basic tree terminologies like Nodes, Edges, Root, Parent, Children, Leaves and Siblings. In next article on tree terminologies, we will see  terms like Degree of Tree, Path, Level, Depth, Height of tree and sub tree. 

How tree is different than other data structures? 

Array, Stack, Queue and Linked List are Linear data structures where as Tree is non- linear data structure like Graph.

But tree is special form of graph having only one path between any two nodes. Tree is a special case of graph having no loops, no circuits and no self-loops.

A tree is an ideal data structure for representing hierarchical data. Lets start with some of the basic terminologies being used for ​Tree.

Tree Data Structure

Tree Terminologies / Tree Vocabulary


Nodes and Edges/Branches

Tree is a type of data structure in which each element is attached to one or more elements directly beneath it. These elements are called Nodes and the connections between them are called branches. If we have total N nodes in tree, then we can have maximum N-1 edges between them. e.g in below Tree, there are 10 nodes and 9 edges.

Nodes vs Edges in Tree data structure


Root Node

Top most node of the Tree is called root of the Tree. We can say that root node is the origin of Tree data structure. Every Tree must have exact one root node (Not less not more). In above tree, is a root Node.


Parent

In tree data structure, Node which has at least one child node is known as Parent Node.  Parent Nodes (except root Node) are also known as Internal Nodes or Non-Terminal nodes. If there are more than one nodes in tree, then Root Node is also a Parent Node  or Internal Node.


Children

In a tree, a Parent can have any number of child nodes. All nodes except Root Node are children.


Leaf Nodes

In a tree, Node which does not have any child is called Leaf Node. Leaf nodes are also known as External Nodes or Terminal Nodes. In other words, all the nodes except leaf nodes are parent nodes.

Parents and Children Tree Data Structure

Trees are often called Inverted Tree  because  they are normally drawn  with root  at the top and leaves at bottom.


Siblings

Nodes which belong to same parent are called siblings.

 

siblings in Tree data structure


Liked this article? Take a second to support CodePumpkin on Patreon!

Tags: ,


Comments and Queries

If you want someone to read your code, please put the code inside <pre><code> and </code></pre> tags. For example:
<pre><code class="java"> 
String foo = "bar";
</code></pre>
For more information on supported HTML tags in disqus comment, click here.
Contribute Your Articles

Interview Experiences

Subscribe Us

Like Us On Facebook

Support Code Pumpkin on Patreon!