Ad Block Detected!
Our website is made possible by displaying ads to our visitors. Please support us by whitelisting our website or allowing necessary trackers.
Our website is made possible by displaying ads to our visitors. Please support us by whitelisting our website or allowing necessary trackers.
A graph is a dynamic data structure that can represent non-linear relationships betweens different items.
Root node
Child Nodes
Parent 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 and the larger value to the right. 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. Because the number 6 is smaller than the number 7, it will be moved to the left and placed there. The n umber ten is greater than 9, so it goes to the right, but it is less than 11, so it goes to the left. The binary tree is built in the order of the given list.