4.1.7.2 Types of Trees (Binary Tree, AVL Trees)
Computational Structures
Trees come in various types, each with its own unique structure and purpose. There are two common types of trees: Binary Trees and AVL Trees. These types help in organizing and managing data in efficient ways.
1. Binary Tree:
A binary tree is a hierarchical data structure in which each node can have at most two children, known as the left and right children as shown in Figure 4.9. This structure is analogous to a family tree, where each individual may have up to two descendants, ensuring a well-organized and balanced arrangement of data for efficient management and retrieval.
Example: In the binary tree example shown in figure 4.9:
- The ”Grandparent" is the root, and it has two children, “Parent1" and ”Parent2”.
- Each parent can have their own children (like “Child1”, “Child2”. etc.).
2. AVL Trees:
An AVL tree is a type of binary tree that keeps itself balanced, meaning the height of the tree is managed carefully. If one side of the tree starts getting too tall compared to the other, the tree rearranges itself to maintain balance.