### Tree

Basics of Tree Data Structure PART - 1

• Tree is a non-linear data structure which organizes data in a hierarchical structure and this is a recursive definition.
• A tree is a connected graph without any circuits/cycles.

Tree Terminology-

The important terms related to tree data structure are-

1. Root-

• The first node from where the tree originates is called as a root node.
• In any tree, there must be only one root node.
• We can never have multiple root nodes in a tree data structure.

Here, node A is the only root node.

2. Edge-

• The connecting link between any two nodes is called as an edge.
• In a tree with n number of nodes, there are exactly (n-1) number of edges.

## 3. Parent-

• The node which has a branch from it to any other node is called as a parent node.
• In other words, the node which has one or more children is called as a parent node.
• In a tree, a parent node can have any number of child nodes.

Here,

• Node A is the parent of nodes B and C
• Node B is the parent of nodes D, E and F
• Node C is the parent of nodes G and H
• Node E is the parent of nodes I and J
• Node G is the parent of node K

4. Child-

• The node which is a descendant of some node is called as a child node.
• All the nodes except root node are child nodes.

Here,

• Nodes B and C are the children of node A
• Nodes D, E and F are the children of node B
• Nodes G and H are the children of node C
• Nodes I and J are the children of node E
• Node K is the child of node G

## 5. Siblings-

• Nodes which belong to the same parent are called as siblings.
• In other words, nodes with the same parent are sibling nodes.

• Nodes B and C are siblings
• Nodes D, E and F are siblings
• Nodes G and H are siblings
• Nodes I and J are siblings

## 6. Degree-

• Degree of a node is the total number of children of that node.
• Degree of a tree is the highest degree of a node among all the nodes in the tree.

### Example-

Here,

• Degree of node A = 2
• Degree of node B = 3
• Degree of node C = 2
• Degree of node D = 0
• Degree of node E = 2
• Degree of node F = 0
• Degree of node G = 1
• Degree of node H = 0
• Degree of node I = 0
• Degree of node J = 0
• Degree of node K = 0
Remaining Tree Terminologies are discussed in my next article (Basics of Tree Data Structure PART - 2)
Please Like if you felt it useful.

#### More Articles of Shaik Ismail:

Name Views Likes
C++ Counting Sort 2027 1
C++ Shutdown Using C++ Code 5745 1
C++ Basics of Graph Data Structure 1648 0
C++ Selection Sort 1438 0
C++ Mirror Binary Tree 836 0
C++ AVL Rotations 2495 0
C++ Merge Sort 6012 0
C++ Graph Representation 703 0
C++ Insertion Sort 627 0
C++ Heap Sort 1582 0
C++ BFS in Graph 4547 0
C++ Deletion in Heaps 6538 0
C++ Check if a binary tree is a BST or not 1576 0
C++ Deletion of Nodes in BST 5297 0
C++ Identical Binary Trees 557 0
C++ Insertion of Nodes in BST 550 0
C++ Single Number LeetCode Bit Manipulation 1982 0
C++ Lowest Common Ancestor 1517 0
C++ Kth Largest Element in BST 858 0
C++ Height of the Binary Tree (Code) 976 0
C++ DFS for a Graph 6023 0
C++ Diameter of a Binary Tree 1914 0
C++ Binary Tree Representation and Traversals (Code) 664 1
C++ Basics of Tree Data Structure PART - 2 700 0
C++ Vertical Order Traversal of a Binary Tree 887 0
Basics of Tree Data Structure PART - 1 426 0
C++ Basics of Heap Data Structure 1420 0
CPP Project or program to get six subjects marks of a student and then calculate its total, average and percentage and display them on the screen 419 0
C++ Basics of BST Part - 1 750 0
C++ Searching in BST 629 0
C++ AVL Tree 883 0
Tree 447 1
C++ Missing Number(LeetCode) 2201 0
C++ Insertion of Elements in Heap 3906 0
C++ Level Order Traversal of a Binary Tree 956 0
C++ Binary Tree 722 0
C++ DNF Algorithm for Sorting 0,1,2 1780 0
C++ Wave Sort 944 0
C++ Binary Tree is a SumTree or Not 411 0
C++ Deletion in AVL Trees 686 0
C++ Quick Sort 4763 0
C++ Power of Two Leetcode BitManipulation 1000 0
C++ Bottom View of a Binary Tree 437 0
C++ Kth Smallest Element in BST 960 0
C++ Bubble Sort 713 0
C++ Top View of a Binary Tree 488 0
C++ Majority Element (LeetCode) 1043 0
C++ Sum of all leaf nodes 414 0
C++ Graph Representation (Adjacency list) 2736 0
C++ Count set bits in an integer 1510 0