Trees are a hierarchical data structure represented by nodes. Each node will have a value and possible children.
Terminology
Root - The first node in a tree.
Height - The length of the longest path from the root to the furthest child node.
Leaves - Nodes without children.
Binary Tree - A tree that has at most 2 children. Usually described as left or right.
General Tree - any tree with 0 or more children.
Binary Search Tree - a tree which has a specific ordering and at most 2 children nodes.
Balanced - a tree is considered to be balanced when the left and right children are of the same height.
Branching Factor - the amount of children that a tree has, for example, a binary tree has a branching factor of 2.
Traversal - The process by which each node in a tree is visited. The two main methods for tree traversal are Depth First Traversal and Breadth First Traversal.
Conclusion
The aim of this article was to serve as an introduction to trees. The next articles will go into detail about the types of tree traversal.
Top comments (0)