AdBlock Detected!
Our website is made possible by displaying ads to our visitors. Please support us by whitelisting our website.
Our website is made possible by displaying ads to our visitors. Please support us by whitelisting our website.
A tree is a dynamic data structure that can represent non-linear relationships betweens different items.
Root node
Child NodesParent Nodes
Edges
In a tree, a root node is the starting node, and edges are what connects the nodes together. The child nodes derive from the parent nodes. The number of edges in a tree is equal to the number of nodes - 1. E = N -1.
A binary tree is a dynamic data structure with nodes only being able to hold a maximum of two other nodes.
Binary trees are built by connecting the smaller value of a parent node to the left child node and the larger value to the right child node. The example below shows a binary tree with the numbers [9, 7, 11, 6, 8, 5, 11, 10] inserted in this order. A quick explanation is that the number 6 is smaller than the number 9 (the root node) so it moves to the left child node. Because the number 6 is smaller than the number 7, it will be moved to the left child node and placed there. The n umber ten is greater than 9, so it goes to the right child node, but it is less than 11, so it goes to the left child node. The binary tree is built in the order of the given list.
To read about binary tree traversals click here or to read about different topics, click here