The common array is a linear data structure. However, a tree is a data structure that is nonlinear--it is hierarchical. Trees are similar to a file system on our computers, and for web dev, the Document Object Model. At the top of a tree is the root node. It may or may not have children; but any child that does exist has a relationship with its parent called an edge. Visually, it looks like a family tree. 
For a tree, a general property of these relationships is that each node has an edge (a connection or relationship) from only one other node. 
For example, parent --edge--> child
However, a parent can have any number of children, and those children can have any number of children, and so on. The general property still holds true: each of those nodes only has one edge from its parent node, except for the root node. In a tree, children do not share an edge with siblings or other parents.
Below is a video, and its associated CodePen, of a tree implementation that I made.

You may also like

Back to Top