It means that in stack and queues, nodes are just pointing towards the next nodes, but in case of tree, these nodes are pointing towards many number of nodes which are called leaves.
for example in the above image- node A is pointing towards 3 other nodes- B, C, D. So A is called parent node and B,C,D are called child or leaf node. Each tree must have a root node that is the parent node of the tree, and in this case the root node is A.
All the nodes are connected with each other through edges. Here B is the parent node for E and F node. Children of same parent are called siblings. So in this case, B, C, D are siblings. E and F are also siblings.
Height if the tree is the number of edges in the longest downward path. So in this case, the height of the tree is 3 - A to B, B to F, F to J.
0 Comments