What is the Trees in DSA? Explanation free notes
Trees in DSA are used for represent the series relationship. Unlike linear data structures such as arrays and linked lists, trees are non-linear and consist of nodes connected by edges, creating a parent-child series.
Key Components
- Nodes:- Each node contains a value or data and links to another nodes (children).
- Root: – The topmost node in tree, which has no parent.
- Edges:- Connections Between nodes, representing the relationship between parent and child.
- Leaf Nodes: – Nodes that do not have any children.
- Subtree: – A tree consisting of a node and its descendands.
Properties of Trees
- Hierarchy (Series):- Trees Model Hierarchical (series) structures such as file systems, organizational charts and classification.
- Acyclic: – Trees do not contain cycles; there is only one path between any two nodes.
- Connected: – All nodes are connected by edges, ensuring there is a path from the root to any node in the tree.
Types of Trees
Here the main types of Trees,
- Binary Tree
- Binary Search Tree (BST)
- Balanced Trees
- Heap Trees