Tree Data Structure and its Applications
What is Tree Data Structure? A tree is a non-linear data structure as it stores data in a hierarchical manner that consists of nodes connected through edges. It is the best alternative for the linear data structure like arrays, stacks, queues, etc as these linear data structures have high time and space complexity. The data stored in nodes of the tree are easier to access thus reducing the time complexity. Terms related to tree data structure 1. Node A node is an entity that stores a data element and links to its child and parent nodes. 2. Edge The link between any two nodes is called the edge. 3. Root The root is the transparent node in a tree that is a root node doesn't have any parent node. Here no. 1 is the Root node. 4. Parent and Child Node The node which contains sub-nodes is called the parent node. Here 1 is the parent node for 2 and 3 and 2 is the parent node for 4 and 5. The node which is a descendant of any node is called a child node. Here 2 and 3 are child nod...