Advanced Data Structures
Tree Data Structure The tree is a non-linear data structure that organizes data in a hierarchical structure and this is a recursive definition. If in a graph, there is one and only one path between every pair of vertices, then the graph is called a tree. Properties- There is one and only one path between every pair of vertices in a tree. A tree with n vertices has exactly (n-1) edges. A graph is a tree if and only if it is minimally connected. Any connected graph with n vertices and (n-1) edges is a tree. Tree Terminology- Root The first node from where the tree originates is called 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. Example Edge The connecting link between any two nodes is called an edge. In a tree with n number of nodes, there is exactly (n-1) number of edges. Example- Parent The node which has a branch from it to any other node is called a parent node. In other words, the node which has one or m...