1. Introduction to Trees
- Tree = Non-linear data structure consisting of nodes connected by edges.
- Root Node – Topmost node.
- Child Node – Node directly connected below another node.
- Parent Node – Node having child nodes.
- Leaf Node – Node with no children.
- Level – Distance from root (root = level 0).
- Depth/Height – Longest path from node to a leaf.
2. Basic Operations in Binary Tree
- Insertion – Add a new node at correct position.
- Deletion – Remove node and adjust tree to maintain structure.
- Traversal – Visit all nodes systematically.
- Pre-order: Root → Left → Right
- In-order: Left → Root → Right
- Post-order: Left → Right → Root
- Pre-order: Root → Left → Right
3. Tree Search and Insertion/Deletion
- Search: Locate a specific node using traversal or binary search in BST.
- Insertion: Add node maintaining Binary Search Tree (BST) property.
- Deletion: Remove node while maintaining BST property:
- Node with no children → delete directly.
- Node with one child → replace node with child.
- Node with two children → replace with inorder predecessor/successor.
- Node with no children → delete directly.
4. Balanced Trees
- Balanced Tree: Height of left and right subtrees differs ≤ 1.
- AVL Tree: Self-balancing binary search tree.
- Rotations:
- Single rotation (Left/Right)
- Double rotation (Left-Right, Right-Left)
- Single rotation (Left/Right)
- Ensures O(log n) height, improving search, insertion, deletion efficiency.
- Rotations:
5. Special Trees
- Huffman Tree
- Used in data compression.
- Build tree using frequency of symbols.
- Used in data compression.
- Game Tree
- Represents possible moves in games.
- Nodes = game states; edges = moves.
- Represents possible moves in games.
- B-Tree
- Multi-way search tree for disk-based storage.
- Maintains balance for efficient search, insert, delete.
- Multi-way search tree for disk-based storage.
6. Applications of Trees
- Database Indexing – B-trees for fast retrieval.
- Expression Parsing – Expression trees for arithmetic evaluation.
- Huffman Encoding – Data compression.
- Decision Making – Game trees, AI algorithms.
- Hierarchical Structures – File systems, organizational charts.
✅ Key Takeaways – Unit 7
- Trees = non-linear hierarchical structure with nodes and edges.
- Traversals: pre-order, in-order, post-order.
- Balanced trees (AVL, B-tree) optimize search and update operations.
- Huffman and game trees are used in compression and AI applications.
- Trees form foundation for efficient algorithms and hierarchical data representation.