Another common nonlinear data structure is the tree.
In this diagram above, we can see that the starting point, or the root node, is circled in blue colour. A node is a simple structure that holds data and links to other nodes.
A D V E R T I S E M E N T
In this case, our root node contains the data string "John" and three links to the other nodes. Notice that the group of nodes circled in red do not have any links(childs). These nodes are at the end of the branches and they are appropriately called as leaves or leaf nodes. In our diagram, the nodes are interconnected with solid black lines called arcs or edges. These edges show the relationships between the nodes in the tree.
One important relationship in the binary tree is the parent-child relationship. Parent nodes have at least one edge to the node lower in the tree. This lower node is called the child node. Nodes can have more than one child, but the children can only have a single parent. Notice that the root node has no parent, and the leaf nodes has no children. Final feature to note in our diagram is the subtree. At each level of the tree, we can see that the tree structure is repeated. For example, the two nodes representing "Charles" and "Rick" compose a very simple tree with "Charles" as the root node and and "Rick" as a single leaf node.
Trees are implemented in the computer's memory. We will begin by introducing the simple tree structure called the binary tree. Binary trees have the restriction that nodes can't have more than two children. With this restriction, we can easily determine how to represent a single binary node in the memory. Our node will need to reserve memory for the data and two pointers(for pointing two childs of that node).
Structure of a binary node:
Using our binary nodes, we can construct a binary tree. In the data cell of each node, we will can store a letter. The physical representation of our tree might look something like the figure below:
No Data Structures Using C Articles could be found as of now.
Share And Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
Keywords:
Tree programming, trees c++, tree c++, tree programming, binary tree c++, binary search tree c++, trees in c++, trees data structures, source code programming, programming data structures, trees tutorial, identification trees, recursion programming, trees algorithms