![]() The easiest way to find the depth is to start at the root node and then count the number of edges that exist between a certain node and the root. Depth: The distance that a node is from the root node.That node and all of the nodes below it is a sub-tree. ![]() Sub-tree: A sub-tree is a section of the main tree.Here are a few more key terms that are helpful for when talking about trees. Finally, nodes B, D, E, and F are leaf nodes as they do not have any child nodes. They are sibling nodes because they both have node C as a parent. Nodes B, C, and D share the same parent node A. Node C is a parent node to child nodes E and F. A is also the parent node to child nodes B, C, and D. Using the above figure, let’s go over some of these terms that we have just learned. Leaf Node: A node that doesn’t have any Child Node.Sibling Node: Nodes that have the same Parent Node.Child Node: A node which is linked to an upper node (Parent Node).Parent Node: A node which is connected to one or more nodes on the lower level (Child Nodes).Link/Edge: The connection between a Parent Node and a Child Node. ![]() Let us start by becoming familiar with some key terms. Instead, let us make sure that we know what a tree is. This post will not focus on the traversal of trees. Non-linear data structures are not organized sequentially like linear data structures are, so it only makes sense that they have to be traversed non-sequentially.ĭon’t worry though. They are only able to be traversed sequentially. Arrays and linked lists are linear data structures. In my previous post I discussed arrays and linked lists. There are certainly some differences between the two though. Trees are similar to linked lists in that they are made up of nodes and links.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |