The tree is considered as a most flexible, versatile and powerful data structure which is used in representing the data processing in a hierarchical relationship. It is one of the important data structure in the field of computer science.
We can also define a tree as a finite set of one or more data item which is also called node such that-
- There is a special node called the root of the tree.
- The remaining node is partitioned into n>=0 disjoint subset, each of which is itself a tree, and they are called subtree.
In simpler words, a tree is a non-linear data structure in which items are arranged in a stored sequence. it is used to represent hierarchical relationship existing amongst several data items.
Fig 1 shows a tree with 18 nodes. the root node N1 has three subtrees T1, T2, T3 and roots of these subtrees are N2, N3, N4 respectively.
The number of subtrees of a node is called its degree, root N1 has degree 3. A node with degree zero is called a leaf node. The leaf nodes are also called terminal nodes.
If x is the root node and its subtrees are T1, T2, T3, and roots of subtrees are R1, R2, R3 then R1, R2, R3 are the children of x. In turn, x is called the parent of R1, R2, and R3. Children of the same parent are called siblings.
In Fig1 N1 is the parent of N2, N3, N4 hence N2, N3, N4 are siblings. The Degree of a tree is the maximum degree of the node in the tree. The tree in Fig1 has degree 5.
The ancestors of a node are all the nodes along the path from the root to that node. The ancestor of N14 is N5, N2, and N1. The descendants of a node are all the nodes along the path from a node to the terminal node. The descendants of N1 are N2, N5, and N14.
Each node of a tree is assigned a level number as follows – The root node R of the tree is assigned a level number 0, and a node is assigned a level number, which is one more than the level number of its parent(root) of the subtree to which it belongs. The nodes, which are at the same level numbers, are said to be of the same generation.
The height or depth of a tree is the maximum number of nodes in a branch. This turns out to be one more than the largest number of tree.
A tree is a strong data processing schema of data structure that is used to store the data item inside it and process it as per requirement. There are a few tree traversing technique which is used to process the data. A degree of the tree is calculated as the total number of subtree or node attached to that node in a tree.
In the case of any queries, you can write to us at firstname.lastname@example.org we will get back to you ASAP.
Hope! you would have enjoyed this post about a Tree in the data structure.
Please feel free to give your important feedbacks in the comment section below.
Have a great time! Sayonara!
- Important facts about Gmail in Hindi? Gmail के बारे में कुछ रोचक तथ्य?
- Software Maintenance Issues & Problem in Hindi? सॉफ्टवेयर मेंटेनेंस मुद्दा और दिक्कते हिंदी में
- What is Requirement engineering in Hindi& Requirement analysis?रेक्विरेमेंट इंजीनियरिंग क्या होता है?
- White Box Testing in Hindi? वाइट बॉक्स टेस्टिंग क्या है हिंदी में?
- Compare and contrast the important life cycle models in Hindi: लाइफ साइकिल मॉडल्स इन हिंदी 2019?
- What is Spiral Model In Hindi? स्पाइरल मॉडल क्या है?
- Rapid Application Development Model in Hindi (RAD Model)? रेड मॉडल क्या है ?
- Incremental Model in Software Engineering? इंक्रीमेंटल मॉडल क्या होता है?
- Waterfall model(वॉटरफॉल मॉडल ) is not used in making bigger software system in Hindi?
- Difference between waterfall and prototype Model in Hindi: वॉटरफॉल मॉडल और प्रोटोटाइप मॉडल में अंतर