Tree
A Tree is a non-linear, hierarchical data structure that consists of a collection of nodes connected by edges.
though in computer science, we usually draw them "upside down" with the root at the top.
Key Terminology
To understand trees, you need to know the specific names for their parts:
Root: The topmost node of the tree.
It is the only node with no parent. Edge: The connecting link between two nodes.
Parent: A node that has one or more child nodes branching from it.
Child: A node that is a descendant of another node.
Leaf (External Node):
A node that has no children; it is the "end" of a branch. Internal Node: A node with at least one child
Subtree: Any node can be viewed as the root of its own smaller tree (a subtree).
Degree: The total number of children a specific node has.
Measuring a Tree
Level: The distance from the root.
The root is at level 0, its children are at level 1, and so on. Depth: The number of edges from the root to a specific node.
Height: The number of edges on the longest path from a node to a leaf.
The Height of the Tree is the height of the root node.
Comments
Post a Comment