-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1introductionToTress.cpp
25 lines (23 loc) · 3.17 KB
/
1introductionToTress.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//Tree Data Structure is a non-linear data structure in which a collection of elements known as nodes are connected to each other via edges such that there exists exactly one path between any two nodes.
// A tree data structure is a hierarchical structure that is used to represent and organize data in a way that is easy to navigate and search. It is a collection of nodes that are connected by edges and has a hierarchical relationship between the nodes. 0
// Parent Node: The node which is a predecessor of a node is called the parent node of that node. {B} is the parent node of {D, E}.
// Child Node: The node which is the immediate successor of a node is called the child node of that node. Examples: {D, E} are the child nodes of {B}.
// Root Node: The topmost node of a tree or the node which does not have any parent node is called the root node. {A} is the root node of the tree. A non-empty tree must contain exactly one root node and exactly one path from the root to all other nodes of the tree.
// Leaf Node or External Node: The nodes which do not have any child nodes are called leaf nodes. {K, L, M, N, O, P, G} are the leaf nodes of the tree.
// Ancestor of a Node: Any predecessor nodes on the path of the root to that node are called Ancestors of that node. {A,B} are the ancestor nodes of the node {E}
// Descendant: A node x is a descendant of another node y if and only if y is an ancestor of y.
// Sibling: Children of the same parent node are called siblings. {D,E} are called siblings.
// Level of a node: The count of edges on the path from the root node to that node. The root node has level 0.
// Internal node: A node with at least one child is called Internal Node.
// Neighbor of a Node: Parent or child nodes of that node are called neighbors of that node.
// Subtree: Any node of the tree along with its descendant.Parent Node: The node which is a predecessor of a node is called the parent node of that node. {B} is the parent node of {D, E}.
// Child Node: The node which is the immediate successor of a node is called the child node of that node. Examples: {D, E} are the child nodes of {B}.
// Root Node: The topmost node of a tree or the node which does not have any parent node is called the root node. {A} is the root node of the tree. A non-empty tree must contain exactly one root node and exactly one path from the root to all other nodes of the tree.
// Leaf Node or External Node: The nodes which do not have any child nodes are called leaf nodes. {K, L, M, N, O, P, G} are the leaf nodes of the tree.
// Ancestor of a Node: Any predecessor nodes on the path of the root to that node are called Ancestors of that node. {A,B} are the ancestor nodes of the node {E}
// Descendant: A node x is a descendant of another node y if and only if y is an ancestor of y.
// Sibling: Children of the same parent node are called siblings. {D,E} are called siblings.
// Level of a node: The count of edges on the path from the root node to that node. The root node has level 0.
// Internal node: A node with at least one child is called Internal Node.
// Neighbor of a Node: Parent or child nodes of that node are called neighbors of that node.
// // Subtree: Any node of the tree along with its descendant.