4.1.6.1 Properties of Trees
Computational Structures
- Root Node: The root is the very first or top node in a tree, like the main folder in a computer where all other folders and files are contained.
- Edges and Nodes: Nodes are the individual elements in the tree, and they are connected by lines called edges. A node without any child nodes is called a leaf, similar to a file in a folder that doesn't contain any other files.
- Height: The height of a tree is the longest path from the root node down to the farthest leaf. It tells us how deep or tall the tree is.
- Balanced Trees: A tree is considered balanced if the branches on the left and right sides are nearly the same height. See the details in Section 4.1.7
Here's a simple example of how to create a family tree structure in Python using classes. This implementation shows how to create family members (nodes) and how to add children (descendants) to them.
python
class FamilyMember:
def __init__(self, name):