What is the Trees in DSA? Explanation free notes

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

  1. Nodes:- Each node contains a value or data and links to another nodes (children).
  2. Root: – The topmost node in tree, which has no parent.
  3. Edges:- Connections Between nodes, representing the relationship between parent and child.
  4. Leaf Nodes: – Nodes that do not have any children.
  5. Subtree: – A tree consisting of a node and its descendands.
Trees in DSA

Properties of Trees

  1. Hierarchy (Series):- Trees Model Hierarchical (series) structures such as file systems, organizational charts and classification.
  2. Acyclic: – Trees do not contain cycles; there is only one path between any two nodes.
  3. 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,

  1. Binary Tree
  2. Binary Search Tree (BST)
  3. Balanced Trees
  4. Heap Trees

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top