Tree Data Structure Terminologies – Set 1
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?
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 Terminologies / Tree Vocabulary
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.
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, A is a root Node.
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.
In a tree, a Parent can have any number of child nodes. All nodes except Root Node are children.
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.
Trees are often called Inverted Tree because they are normally drawn with root at the top and leaves at bottom.
Nodes which belong to same parent are called siblings.
That's all for this topic. If you guys have any suggestions or queries, feel free to drop a comment. We would be happy to add that in our post. You can also contribute your articles by creating contributor account here.
Happy Learning 🙂
If you like the content on CodePumpkin and if you wish to do something for the community and the planet Earth, you can donate to our campaign for planting more trees at CodePumpkin Cauvery Calling Campaign.
We may not get time to plant a tree, but we can definitely donate ₹42 per Tree.
About the Author
Comments and QueriesIf 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.